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

feat(executioncontext): warn on nested js handle #3591

Merged
merged 6 commits into from
Jan 14, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 16 additions & 9 deletions lib/ExecutionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,21 @@ class ExecutionContext {
throw new Error('Passed function is not well-serializable!');
}
}

const { exceptionDetails, result: remoteObject } = await this._client.send('Runtime.callFunctionOn', {
functionDeclaration: functionText + '\n' + suffix + '\n',
executionContextId: this._contextId,
arguments: args.map(convertArgument.bind(this)),
returnByValue: false,
awaitPromise: true,
userGesture: true
}).catch(rewriteError);
let funcCallResultP;
try {
funcCallResultP = this._client.send('Runtime.callFunctionOn', {
functionDeclaration: functionText + '\n' + suffix + '\n',
executionContextId: this._contextId,
arguments: args.map(convertArgument.bind(this)),
returnByValue: false,
awaitPromise: true,
userGesture: true
});
} catch (err) {
err.message += ' Are you passing a nested JSHandle?';

Choose a reason for hiding this comment

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

You do want to check if it's a TypeError still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, right. I'll add that back.

throw err;
}
const { exceptionDetails, result: remoteObject } = await funcCallResultP.catch(rewriteError);
if (exceptionDetails)
throw new Error('Evaluation failed: ' + helper.getExceptionMessage(exceptionDetails));
return createJSHandle(this, remoteObject);
Expand Down Expand Up @@ -162,6 +168,7 @@ class ExecutionContext {
throw new Error('Execution context was destroyed, most likely because of a navigation.');
throw error;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: stray line

}

/**
Expand Down