Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

First fix for not immune to while(1){} #244

Merged
merged 2 commits into from
Sep 14, 2019

Conversation

XmiliaH
Copy link
Collaborator

@XmiliaH XmiliaH commented Sep 14, 2019

This does not fix the Promise & async problems

@XmiliaH XmiliaH requested a review from patriksimek September 14, 2019 12:06
@XmiliaH
Copy link
Collaborator Author

XmiliaH commented Sep 14, 2019

And for the async problem I currently have no idea to fix it.

lib/main.js Outdated
};

const TIMEOUT_CONTEXT = vm.createContext();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest changing that to const TIMEOUT_CONTEXT = null and moving vm.createContext() inside the doWithTimeout function. Just a performance tweak for situations when timeout is not used.

} catch (e) {
throw this._internal.Decontextify.value(e);
}
return doWithTimeout(()=>{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use doWithTimeout only when timeout is specified. Related to my previous comment.

@XmiliaH XmiliaH requested a review from patriksimek September 14, 2019 21:56
@patriksimek patriksimek merged commit a63bef7 into patriksimek:master Sep 14, 2019
@patriksimek
Copy link
Owner

Thanks.

@OrkhanAlikhanov
Copy link

@XmiliaH What are the "Promise & async problems"? Couldn't find mention of it anywhere

@XmiliaH
Copy link
Collaborator Author

XmiliaH commented Oct 23, 2019

@OrkhanAlikhanov see #180 (comment). However, there is currently a PR #246 that tries to address this issue by disallowing scripts with the word async and patching Promise. This has some sideeffects, for example eval can't be used as direct eval any more.

@OrkhanAlikhanov
Copy link

Thank you for the quick response!

@fangk
Copy link

fangk commented Jan 15, 2020

https://medium.com/@bvjebin/js-infinite-loops-killing-em-e1c2f5f2db7f
can we use babel inject code into WhileStatement and ForStatement?

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

Successfully merging this pull request may close these issues.

4 participants