nw.js: URL.createObjectURL fails on 0.76.1
Issue Type
Before opening an issue, please search and see if it has already been raised.
-
Bug Report
-
Feature Request
-
Successfully reproduced against the latest version of NW.js?
Please use our mailing list or Gitter chatroom to ask questions. The issue tracker is only for bugs and feature requests, in English only. Please note that issues without a repro or code snippet are less likely to be resolved.
Current/Missing Behavior
URL.createObjectURL(new Blob([]))
is the minimal code needed to reproduce the issue. In 0.76.1 the following error message is produced, regardless of input.
Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
Expected/Proposed Behavior
The expected behavior is that a URL to the blob is returned, such as:
blob:chrome-extension://hjnamambhlpahhgnmkmdplebghbjncpm/b1957c09-3e5c-48d3-b545-8052ddb77d3c
This works as expected on 0.75.0.
Additional Info
- Operating System: Windows
- NW.js Version: 0.76.1
- Repro Link:
- Code snippet:
URL.createObjectURL(new Blob([]))
- Crash report:
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (4 by maintainers)
Please test this build: https://dl.nwjs.io/live-build/nw85/20240305-222312/9b99df3ea/v0.85.1/
I think I found a minimal repro for this: nwjs-issue8075.zip
It’s true that
URL.createObjectURL(blob)
fails in a worker only in recent versions of NW.js, but only when specifying"chromium-args": "--enable-node-worker"
in package.json, which some frameworks (like ours) do.In this case, in the context of the worker, the
Blob
constructor actually appears to be a version from Node.js (apparently fromnode:internal/blob
) that overrides the browser one. Therefore since it’s not a real Blob that the browser understands, methods likeURL.createObjectURL
fail, but also checks likeinstanceof Blob
also fail.Hopefully this is enough information to be able to fix the issue now - we’re seeing reports of this from time to time (e.g. here).
@rogerwang - is an official NW.js 0.85.1 release coming up for this? Apparently the issue is affecting some Construct games, and it would be useful to know if a release is scheduled, or if we ought to be using a one-off build (which I’m a bit reluctant about as normally nightly releases are not as reliable)
From my testing, this is only broken inside workers, not on the main thread
Worker disabled: https://drive.google.com/file/d/1KO2yJpoG3yo7fXO0i64iWeTAwpZG_5-A/view?usp=drive_link
Worker enabled: https://drive.google.com/file/d/1_k4_dQT8B1XWPcjUNGnqAAdNGaMxV330/view?usp=drive_link
(Sorry, file too big for Github)
The bug still happens in 0.77.0