Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

v3.0.61 some globals missing #488

Closed
dnalborczyk opened this issue Jul 2, 2018 · 7 comments
Closed

v3.0.61 some globals missing #488

dnalborczyk opened this issue Jul 2, 2018 · 7 comments
Labels

Comments

@dnalborczyk
Copy link
Contributor

dnalborczyk commented Jul 2, 2018

still converting tests to use esm and jest and noticed that some (other) globals are missing. 😕

scenario is the same as #487, and the same repro can be used: https://github.com/dnalborczyk/esm-jest-repro/tree/jest-no-global (with v3.0.61, fixes global)

I made a list based off: https://nodejs.org/api/globals.html. not sure if the list is conclusive , nor do I know if everything even should exist (e.g. __dirname, require, etc.):

global object status
Buffer exists
__dirname exists
__filename exists
clearImmediate exists
clearInterval does not exist
clearTimeout does not exist
console exists
exports exists
global exists
module exists
process exists
require exists
setImmediate exists
setInterval does not exist
setTimeout does not exist
URL does not exist
URLSearchParams does not exist

in addition:

global object status
util does not exist (note: global.util does not exist as well)
@jdalton
Copy link
Member

jdalton commented Jul 2, 2018

Hmm okay!

Before I was using the global jest provides us (not the real global). It looks like what they are providing is a little incomplete. I can mesh the two globals (using the real global to fill in the gaps of jest). Thanks for the detailed report btw. It's always super helpful to see something like that.

@dnalborczyk
Copy link
Contributor Author

no problem! same goes back to you, thank you!!!

@dnalborczyk
Copy link
Contributor Author

btw, I forgot to mention, I'm sure you know: URL and URLSearchParams only exist in node v10+

I also just noticed that util is a node.js global as well. I'll add it to the list above.

@jdalton jdalton closed this as completed in 19efd9a Jul 2, 2018
@jdalton
Copy link
Member

jdalton commented Jul 3, 2018

Patched 19efd9a and 2bf85e9.

Update:

This was interesting and may be an engine bug. I noticed that the unsafeGlobal (aka global) would have the URL and URLSearchParams properties on it but they weren't showing up as free vars. When I would get the keys on the global the keys for URL and URLSearchParams would be missing (even when using Reflect.ownKeys and Object.getOwnPropertyNames).

However, global.hasOwnProperty("URL") and Reflect.getOwnPropertyDescriptor(global, "URL") would return positive results. So I found that one way to get them to show up was to delete them and re-add them exactly as they were (that is why it looks like an engine bug).

@jdalton jdalton added the bug label Jul 3, 2018
@dnalborczyk
Copy link
Contributor Author

that's indeed weird. do you mean by possible "engine bug" V8?

just curious, is this reproducible without jest and esm?

@jdalton
Copy link
Member

jdalton commented Jul 3, 2018

@dnalborczyk

just curious, is this reproducible without jest and esm?

I have a few hunches. I suspect it has to do with an object uses as the context for multiple vm.Script instances.

Update:

v3.0.62 is released 🎉

@dnalborczyk
Copy link
Contributor Author

nice, thanks!! all tests are passing! 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants