mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(workers): workaround worker execution context flakiness (#2596)
Some of the worker tests were failing on the bots. After investigating, I found one race in the test, and one race upstream in Chromium which I filed upstream as https://crbug.com/846099. But I added a small hack here as a temporary workaround. References #2632
This commit is contained in:
committed by
Andrey Lushnikov
parent
469b910a2d
commit
1c2adf61e9
@@ -28,7 +28,13 @@ class Worker extends EventEmitter {
|
||||
this._client = client;
|
||||
this._url = url;
|
||||
this._executionContextPromise = new Promise(x => this._executionContextCallback = x);
|
||||
this._client.on('Runtime.executionContextCreated', event => {
|
||||
this._client.once('Runtime.executionContextCreated', async event => {
|
||||
// Get a reference to the main object on the worker as a hack around https://crbug.com/846099.
|
||||
await this._client.send('Runtime.evaluate', {
|
||||
expression: 'this',
|
||||
returnByValue: false,
|
||||
contextId: event.executionContextId
|
||||
}).catch(debugError);
|
||||
const jsHandleFactory = remoteObject => new JSHandle(executionContext, client, remoteObject);
|
||||
const executionContext = new ExecutionContext(client, event.context, jsHandleFactory, null);
|
||||
this._executionContextCallback(executionContext);
|
||||
|
||||
Reference in New Issue
Block a user