From 715aad2d672958f8f394fbd9bb65c9a84edf9db1 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Fri, 12 Jul 2019 17:19:02 -0700 Subject: [PATCH] fix: proper parse Error message on Node 12 (#4698) 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. --- experimental/puppeteer-firefox/lib/ExecutionContext.js | 2 +- lib/ExecutionContext.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/experimental/puppeteer-firefox/lib/ExecutionContext.js b/experimental/puppeteer-firefox/lib/ExecutionContext.js index d74c12fc2e5..26ccb7b2dfd 100644 --- a/experimental/puppeteer-firefox/lib/ExecutionContext.js +++ b/experimental/puppeteer-firefox/lib/ExecutionContext.js @@ -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; } diff --git a/lib/ExecutionContext.js b/lib/ExecutionContext.js index 9a4ac6236b7..cda3899d1ee 100644 --- a/lib/ExecutionContext.js +++ b/lib/ExecutionContext.js @@ -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; }