Skip to content

Commit

Permalink
fix: proper parse Error message on Node 12 (puppeteer#4698)
Browse files Browse the repository at this point in the history
Check message prefix rather than strict equality when detecting circular JSON error. The message format has changed in Node 12 which broke the condition and failed a test.
  • Loading branch information
yury-s authored and aslushnikov committed Jul 13, 2019
1 parent 49b2795 commit 715aad2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion experimental/puppeteer-firefox/lib/ExecutionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ExecutionContext {
executionContextId: this._executionContextId
});
} catch (err) {
if (err instanceof TypeError && err.message === 'Converting circular structure to JSON')
if (err instanceof TypeError && err.message.startsWith('Converting circular structure to JSON'))
err.message += ' Are you passing a nested JSHandle?';
throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ExecutionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ExecutionContext {
userGesture: true
});
} catch (err) {
if (err instanceof TypeError && err.message === 'Converting circular structure to JSON')
if (err instanceof TypeError && err.message.startsWith('Converting circular structure to JSON'))
err.message += ' Are you passing a nested JSHandle?';
throw err;
}
Expand Down

0 comments on commit 715aad2

Please sign in to comment.