-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix: panic, unwrap to unwrap_or #739
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Could you add a test? Maybe use unwrap_or_else
instead?
@ry |
@ry |
@peko-thunder can you please run |
Instead of concealing the bug like this, can we fix |
@0f-0b can you elaborate more on the suggested solution? |
@bartlomieju |
The ultimate cause of this bug is that |
@devsnek what do you think of the approach above? |
assuming you are referring to this Line 172 in 87e5ab2
i think applying both approaches make sense. runtime internal js should have a way to push an element to an array without the prototype breaking things, and runtime internal rust should probably be able to cope with weird things happening in js without crashing, unless the weird thing is truly a case where the runtime cannot safely continue execution. |
Thanks for the suggestion.
|
Confirmed that all tests pass.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The panic may still happen if user code overwrites __callSiteEvals
. I will investigate if it is possible to hide __callSiteEvals
from user code later.
throw Object.defineProperty(new Error(), "__callSiteEvals", { value: [0] });
ObjectDefineProperty
is really slow, but we can always replace ArrayPrototypePush(array, value)
with array[array.length] = value
in affected code. The latter is not only much faster, but also makes it explicit that [[Set]]
is called.
Yeah I would suggest keeping the rust
For hiding |
Why wasn't Edit: I see that a lot of useful information is only available to the |
Co-authored-by: ud2 <[email protected]>
…rototype`. Co-authored-by: ud2 <[email protected]>
primordials.ArrayPrototypePush = (thisArray, ...args) => { | ||
for (let i = 0; i < args.length; i++) { | ||
ObjectDefineProperty(thisArray, thisArray.length, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a PR in
deno_core
to correct the issue.Sometimes
panic
occurs withunwrap()
.So I set the default value.
Do I need to write test code?
I'm reading the code right now, it's going to take some time.