In fastboot sandbox the `URL` global object is not WHATWG URL
See original GitHub issueSince Node.js 10 the URL
is available as global variable, and it is WHATWG URL API - “Browser-compatible URL class, implemented by following the WHATWG URL Standard”.
But under fastboot I can not use new URL(...)
, because sandbox globals assigns URL
to require('url')
.
https://github.com/ember-fastboot/ember-cli-fastboot/blob/9e0b053cced1189ffeaafa827a386a8f82a1b788/packages/fastboot/src/sandbox.js#L17-L26
It’s very confusing because:
- it differs from nodejs, where
globalThis.URL === require('url').URL
- I can’t write code
new URL(...)
in app that will be valid for both environments - browser and fastboot. Instead, I have to write like thisIS_FASTBOOT ? new URL.URL(...) : new URL(...)
or usebuildSandboxGlobals
to assignURL
torequire('url').URL
instead of defaultrequire('url')
.
In my opinion, the URL
global variable in fastboot should be the same as for Node.js:
- let URL = require('url');
+ let { URL } = require('url');
let globals = this.globals;
let sandbox = Object.assign(
{
sourceMapSupport,
console,
setTimeout,
clearTimeout,
URL,
Also, it make sense because support of Node < 10 has been dropped here (#695).
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Is There A Bug In Node.Js Pathtofileurl()/Fileurltopath()?
Ask questionsIn fastboot sandbox the URL global object is not WHATWG URL. Since Node.js 10 the URL is available as global variable and...
Read more >Jest URL.createObjectURL is not a function
This would appear to be as simple as setting up URL on the Global in Jest. Something like describe('download', () => { const...
Read more >SideQuest-Setup-0.10.18-x64-win.exe, pid
https://url.spec.whatwg.org/#url, SideQuest.exe, ... Object.getPrototypeOf.bind(global.Object);.const getOwnPropertyDescriptor =.global.Object.
Read more >platform/docs/source.android.com - Git at Google
That is, device implementations MUST NOT alter the triggers or thresholds at which compatibility mode is ... in the Android Open Source Project...
Read more >What's New - Oracle Linux Yum Server
objenesis-1.2-19.el7 - A library for instantiating Java objects (Update) ... rust-url-2.2.2-4.el9 - URL library for Rust, based on the WHATWG URL Standard ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just tripped over this. In an addon, where I cannot influence the sandbox globals, I had to revert to this ugly check:
Would be nice to get this fixed in a stable v3!?
If we want to keep compatibility with the
url
module and at the same time compatibility with the WHATWG API, that would mean not only exposingURL.URL
, but also all the other module exports, right? This is how the export currently looks like when logged:Doable, but also kinda ugly.
Bumping my version of ember-source to 3.22 solved this issue for me. The code throwing the exception is not gone, no other changes needed.