mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(rpc): ensure better error messages when rpc misbehaves (#3838)
- Print parentGuid when it is not available for __create__. Some bots show generic "something is undefined" error - let's get better information about the failure. - Ignore events on disposed objects outside of tests. Some bots show this happening for "previewUpdated" - let's see whether there are more important events that misbehave.
This commit is contained in:
parent
ed3b00efdf
commit
46f9151795
@ -133,7 +133,9 @@ export class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createRemoteObject(parentGuid: string, type: string, guid: string, initializer: any): any {
|
private _createRemoteObject(parentGuid: string, type: string, guid: string, initializer: any): any {
|
||||||
const parent = this._objects.get(parentGuid)!;
|
const parent = this._objects.get(parentGuid);
|
||||||
|
if (!parent)
|
||||||
|
throw new Error(`Cannot find parent object ${parentGuid} to create ${guid}`);
|
||||||
let result: ChannelOwner<any, any>;
|
let result: ChannelOwner<any, any>;
|
||||||
initializer = this._replaceGuidsWithChannels(initializer);
|
initializer = this._replaceGuidsWithChannels(initializer);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -18,7 +18,7 @@ import { EventEmitter } from 'events';
|
|||||||
import * as channels from '../protocol/channels';
|
import * as channels from '../protocol/channels';
|
||||||
import { serializeError } from '../protocol/serializers';
|
import { serializeError } from '../protocol/serializers';
|
||||||
import { createScheme, Validator, ValidationError } from '../protocol/validator';
|
import { createScheme, Validator, ValidationError } from '../protocol/validator';
|
||||||
import { assert, createGuid, debugAssert } from '../utils/utils';
|
import { assert, createGuid, debugAssert, isUnderTest } from '../utils/utils';
|
||||||
|
|
||||||
export const dispatcherSymbol = Symbol('dispatcher');
|
export const dispatcherSymbol = Symbol('dispatcher');
|
||||||
|
|
||||||
@ -75,6 +75,12 @@ export class Dispatcher<Type, Initializer> extends EventEmitter implements chann
|
|||||||
}
|
}
|
||||||
|
|
||||||
_dispatchEvent(method: string, params: Dispatcher<any, any> | any = {}) {
|
_dispatchEvent(method: string, params: Dispatcher<any, any> | any = {}) {
|
||||||
|
if (this._disposed) {
|
||||||
|
if (isUnderTest())
|
||||||
|
throw new Error(`${this._guid} is sending "${method}" event after being disposed`);
|
||||||
|
// Just ignore this event outside of tests.
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._connection.sendMessageToClient(this._guid, method, params);
|
this._connection.sendMessageToClient(this._guid, method, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user