Skip to content
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

What about errors on the prototype chain? #3

Open
mgaudet opened this issue Jan 9, 2025 · 10 comments
Open

What about errors on the prototype chain? #3

mgaudet opened this issue Jan 9, 2025 · 10 comments

Comments

@mgaudet
Copy link

mgaudet commented Jan 9, 2025

Looking at the Firefox implementation, it appears that we explicitly handle the prototype chain in our getter implementation:

This means that

let o = {__proto__: new Error}
o.stack

works; as I read the spec text on this proposal it would currently throw however because o lacks an [[ErrorData]] internal slot.

@ljharb
Copy link
Member

ljharb commented Jan 9, 2025

Your analysis is correct. Is there code on the web that relies on this working? It's very uncommon in the language to have accessors that don't brand check.

@mgaudet
Copy link
Author

mgaudet commented Jan 9, 2025

No idea. We don't have telemetry here to tell us.

@ljharb
Copy link
Member

ljharb commented Jan 9, 2025

What is the appetite for shipping with the check with a pre-agreement to remove it if there's web compat issues?

Meaning, we could easily have two specs - main, plus a PR that removes the checks - and in theory a flag could guard the two variants that could be flipped post-deploy?

@mgaudet
Copy link
Author

mgaudet commented Jan 9, 2025

My appetite is fairly low; I wouldn't be opposed to trying to get some telemetry but not sure when I can slot that in.

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jan 10, 2025

Note that the current spec text returns undefined, rather than throwing.

If E does not have an [[ErrorData]] internal slot, return undefined.

@ljharb
Copy link
Member

ljharb commented Jan 10, 2025

Indeed, closing makes sense, I believe.

@ljharb ljharb closed this as completed Jan 10, 2025
@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jan 10, 2025

Well, it still behaves differently from Firefox and Chrome where o.stack returns a string and not undefined :)

(I have no opinion on what we should do, I'd go with the current behavior if it's web-compatible)

@mgaudet
Copy link
Author

mgaudet commented Jan 10, 2025

I'd leave this open until we had any idea at all what is web compatible.

@ljharb
Copy link
Member

ljharb commented Jan 10, 2025

Sounds good

@ljharb ljharb reopened this Jan 10, 2025
@mgaudet
Copy link
Author

mgaudet commented Jan 10, 2025

(It does appear that Chrome also works this way)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants