Uh oh!
There was an error while loading. Please reload this page.
util: fix isInsideNodeModules() check - #30014
Conversation
Co-authored-by: Andy Locascio <andy@slack-corp.com>
bacdc47 to
7976e06Comparedevsnek
commented
Oct 18, 2019
I made this change so that I think it would serve better for electron to figure out a way to use node's prepareStackTrace. I think you can manually call |
addaleax
commented
Oct 18, 2019
I’d also be good with reverting 70c2444 as an option in general. |
codebytere
commented
Oct 18, 2019
@addaleax happy to help out with whatever the end-solution is here - the repl changes are fine for us so for our purposes we're happy with as thinly-scoped a PR as possible i think! |
I'm not so sure that it's okay to consider a node environment valid if the embedder overrides our hooks into V8. @codebytere do you know why electron is overriding our hook in the first place? |
codebytere
commented
Oct 18, 2019
@devsnek but it's not a hook into v8 as much as a mutable JS prototype, right? Since the current Node.js code relies on a v8 cross-context pollution (linked in my PR body), you all would hit this same issue when you upgraded to our current version of v8 (v7.9.74) that we're currently using in Electron 🤔 |
devsnek
commented
Oct 18, 2019
Our current hook runs for everything within an isolate, it isn't context specific. From there, it does context-specific dispatch (the line with |
codebytere
commented
Oct 22, 2019
@devsnek right - the issue here is that the test relies on Node's version of It seems like a fair assumption that we'd want to have behavior parity between the two versions, which is no longer the case with the change that was made to cause this issue. |
devsnek
commented
Oct 22, 2019
@codebytere node's version is identical except that it also falls back to the old v8 behaviour, which is needed for a lot of packages in the npm ecosystem. I assume electron wants to support those too? Additionally, I'm not sure what setup electron has where its both running node tests but doesn't have a proper node environment, so I can't really provide any good advice to that point. |
codebytere
commented
Oct 22, 2019
The |
devsnek
commented
Oct 22, 2019
@codebytere well yes, but if you're running node tests outside of a node environment with that callback, having failures seems expected to me. |
@devsnek i'm not married to this solution - i'd just like to see if we can find a solution that allows both to work. I'm super happy to switch up my approach in this PR, my goal is just to have |
I still don't understand why electron has disabled node's prepareStackTrace callback. |
@devsnek we don't explicitly disable it; this is at its root because we don't call Node.js' exposed As a result, |
addaleax
commented
Oct 23, 2019
I’ve been wondering for a while whether we should maybe expose the V8 callbacks that we set through our public API … maybe this would be a good start? That would also potentially allow embedders to provide per-Context behaviour when that applies, which would be good imo. If not, I think we should expose the two-argument variant of |
Also to elaborate a bit - we need to use this same isolate to set up |
codebytere
commented
Oct 25, 2019
@devsnek given my explanation above, what are your thoughts on a path forward here? |
devsnek
commented
Oct 25, 2019
if electron doesn't set up the isolate correctly, for whatever reason, things will fail to work correctly. On the node side, maybe we can expose SetUpIsolateForNode? |
codebytere
commented
Dec 5, 2019
Closing this given that we went the allow-custom-callbacks route in the end. |
This PR reverts away from use of
overrideStackTraceinisInsideNodeModules()introduced in #29777.At the moment, Electron uses the v8 version of
Error.prepareStackTraceas defined inv7.9.74(where https://crbug.com/v8/7848 has been fixed) and not the one polyfilled here: #23926. As a result, we were experiencing failures inparallel/test-buffer-constructor-outside-node-modules.jsbecause the polyfilledprepareStackTracewas not being run and thus the following code inside that function would never be executed:so
isInsideNodeModules()would always return false.This change still allows for
isInsideNodeModules()to be tested correctly while retaining correct functionality for Electron. SinceisInsideNodeModules()is only ever invoked when determining whether to print a deprecation warning fornew Buffer(), this change should have no effects on end users.cc @devsnek@loc
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesCo-authored-by: Andy Locascio andy@slack-corp.com