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.
This commit is contained in:
Yury Semikhatsky 2019-07-12 17:19:02 -07:00 committed by Andrey Lushnikov
parent 49b27956fe
commit 715aad2d67
2 changed files with 2 additions and 2 deletions

View File

@ -67,7 +67,7 @@ class ExecutionContext {
executionContextId: this._executionContextId executionContextId: this._executionContextId
}); });
} catch (err) { } 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?'; err.message += ' Are you passing a nested JSHandle?';
throw err; throw err;
} }

View File

@ -113,7 +113,7 @@ class ExecutionContext {
userGesture: true userGesture: true
}); });
} catch (err) { } 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?'; err.message += ' Are you passing a nested JSHandle?';
throw err; throw err;
} }