-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Warning message when there is an attempt to overwrite __proto__ #10222
Comments
Also, perhaps the warning message could point developers to use setPrototypeOf instead? This saved the day for me, and I wouldn't had known about it unless I visited the |
@josephrocca so you're suggesting to print a warning when a code like this is executed: |
@bartlomieju Yes - just the first time that something like that is attempted (future occurrences would be silent). But if it's not feasible, then I'll close this. I think overwriting |
@kitsonk In this comment you mentioned that you'd prefer not to throw an error when
__proto__
is overwritten likefoo.__proto__=bar
(as opposed tosetPrototypeOf
). I wonder what you (and other Deno devs) think about throwing a one-off warning message instead?I'm porting a tangle of browser code across (the node XMLHttpRequest polyfill using browserify, so that I can get Pyodide running in Deno) and just fixed a somewhat "silent" bug that was caused by this. Luckily I'd just created #10221 for curiosity's sake, so it was quicker to track down, but it still took me an hour because I didn't realise that there was another attempted
__proto__
edit in the codebase. I imagine that some others won't have as easy a time, because it's definitly not obvious that__proto__
would be frozen in Deno, while being editable in browsers.I think an error would actually make some sense - better to crash the server (and thus alert the admin) than have silent bugs lurking. But a
console.warn
would be a good middle ground perhaps.Cheers!
The text was updated successfully, but these errors were encountered: