-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maximum call stack size exceeded #13
Comments
I've never worked with Object.defineProperty so I'm having a hard time getting through this code. But I did notice that disabling one of the following two parts in Polyfill.js prevents the issue: toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')), On line 74: toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')), On line 92 - 94: defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function() {
return validateSymbol(this);
})); |
I'm having this problem with |
It's these changes: toPrimitive: d('', SymbolPolyfill('toPrimitive')),
toStringTag: d('', SymbolPolyfill('toStringTag')), To: toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')),
toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')), Reverting one of these changes fixes the issue. |
This issue doesn't occur when using Webpack (instead of SystemJS) Even when using Babel 5.8.34 (instead of 6). |
It looks as some definitive issue with SystemJS (even line number |
(It's at line 92 of the transpiled version, the sourcemap doesn't always work when there are errors) |
A temporary workaround when working with SystemJS is using only 2.0.1: |
While this does only seem to happen in SystemJS, the underlying cause seems to be a loop in the code logic of this repo itself. Running through with the debugger, it shows that: The error thrown by module.exports = function(value) {
if (!isSymbol(value))
throw new TypeError(value + " is not a symbol");
return value;
}; Where
This then cycles between that error and this single line of code: module.exports = function (x) {
return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false;
}; Which seems to in turn trigger the error again. @medikoo do you have any idea at all why such a loop might arise, and how SystemJS could have contributed to getting the logic into such a loop. It would be much easier to track down knowing what specific SystemJS environment changes might have created this in the first place. |
@guybedford If I understand right, you mean that following code: return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; Triggers invocation of function exported by To be honest I have no idea, how it could happen, the only thing that opens door for some hidden code being invoked is here: In scope of es6-symbol, there's no such getter set, there's only a setter defined in one place. Do SystemJS tries to change native |
@medikoo thanks for the quick response. Yes I guess it is that or an implicit
I don't see any getter on Looking at the stack again, the first invocation seems to come from the last line of
|
Could the line |
@guybedford can you prepare some smallest possible (but not minified) test case, that will include two ready files: |
@medikoo thanks so much for offering to look into this further. There is already one at https://github.com/peteruithoven/systemjs-es6-symbol-issue, in the |
@guybedford instructions over there doesn't seem complete. I have no idea what's behind |
@medikoo eg via I've been thinking more about this, and I'm wondering if it could be due to SystemJS doing something like the following internally: var es6SymbolModule = { default: require('es6-symbol') };
Object.keys(es6SymbolModule).forEach(function(key) {
es6SymbolModule[key] = es6SymbolModule.default.key;
}); While this should normally be caught and ignored if it fails, it seems the circular throwing behaviour when trying to access |
There's definitely something done that causes this. Still Object.keys, get only enumerable properties, and all constructor properties on I'm afraid that without a working test case I'm not able to help you (and I'm sorry, but I don't have time to learn how your utilities work just for sake of running simple test). |
I tried to clarify the readme of my example: https://github.com/peteruithoven/systemjs-es6-symbol-issue |
I managed to look into this further and the issue is simply that The reason this happens in SystemJS is due to our static analysis adding all requires as dependencies so that the CommonJS conditional branching breaks down. It might be nice to give a better error in |
@peteruithoven good test case shouldn't require from me install of external utilities or browsing documentation on how to achieve certain things. What I need is plain simple index.html and index.js, that exposes the issue, such things are really easy to prepare with workflow I use, and I believe it's same case on your side.
@guybedford node.js v4 and v5 provide native |
@medikoo a very simple replication would be |
Ok I got it. Cause of that issue is uneven state of implementation in Chrome, which at current stage implements native Line 87 in 54d1436
Both Node.js v4 and v5 doesn't yet use version of V8 that implements Why it crashes: At line
This call tries to validate given symbol object, and validation works by either recognizing native symbol or recognizing mock by it's Fix would be to reorder definitions in polyfill, so definition of |
Published as v3.0.2 |
👍 thanks for the quick response here. |
Thanks for figuring this out guys! |
When I simply import es6-symbol into my code I get a
Maximum call stack size exceeded
error.I'm not sure it's caused by es6-symbol. It could also be caused by the dependency
es5-ext
, but I can't test this separately because these two packages depend on each other.I'm using es6-symbol
v3.0.1
and Chrome47.0.2526.73 (64-bit)
(automatically updated).I'm using SystemJS as module loader and JSPM as package manager.
Full error:
Reproduce:
npm install -g jspm
mkdir test
cd test
jspm init -y
jspm install import es6-symbol
The text was updated successfully, but these errors were encountered: