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

vm: name anonymous functions #9388

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ const realRunInContext = Script.prototype.runInContext;

Script.prototype.runInThisContext = function(options) {
if (options && options.breakOnSigint) {
return sigintHandlersWrap(() => {
const sigintHandler = () => {
Copy link
Member

Choose a reason for hiding this comment

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

If line length is below 80 chars I think it is ok to put the whole function expression on one line.

Copy link
Member

Choose a reason for hiding this comment

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

I am a bit 😕 about the name here… this function does not handle any kind of signal; it’s the exact opposite, the function is run undisturbed by SIGINTs. (The comment/code for sigintHandlersWrap has a bit more information.) So maybe you could call it realRunInThisContext or runScriptUninterruped or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where is the doc you are referring to , i want to understand this a little better

return realRunInThisContext.call(this, options);
});
};
return sigintHandlersWrap(sigintHandler);
} else {
return realRunInThisContext.call(this, options);
}
};

Script.prototype.runInContext = function(contextifiedSandbox, options) {
if (options && options.breakOnSigint) {
return sigintHandlersWrap(() => {
const sigintHandler = () => {
return realRunInContext.call(this, contextifiedSandbox, options);
});
};
return sigintHandlersWrap(sigintHandler);
} else {
return realRunInContext.call(this, contextifiedSandbox, options);
}
Expand Down