mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: connection closed error should be a rejected promise (#12575)
This commit is contained in:
parent
74d9969744
commit
e36ce8bee1
@ -18,7 +18,6 @@ import type {ConnectionTransport} from '../common/ConnectionTransport.js';
|
|||||||
import {debug} from '../common/Debug.js';
|
import {debug} from '../common/Debug.js';
|
||||||
import {TargetCloseError} from '../common/Errors.js';
|
import {TargetCloseError} from '../common/Errors.js';
|
||||||
import {EventEmitter} from '../common/EventEmitter.js';
|
import {EventEmitter} from '../common/EventEmitter.js';
|
||||||
import {assert} from '../util/assert.js';
|
|
||||||
import {createProtocolErrorMessage} from '../util/ErrorLike.js';
|
import {createProtocolErrorMessage} from '../util/ErrorLike.js';
|
||||||
|
|
||||||
import {CdpCDPSession} from './CDPSession.js';
|
import {CdpCDPSession} from './CDPSession.js';
|
||||||
@ -120,8 +119,9 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
|
|||||||
sessionId?: string,
|
sessionId?: string,
|
||||||
options?: CommandOptions
|
options?: CommandOptions
|
||||||
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
): Promise<ProtocolMapping.Commands[T]['returnType']> {
|
||||||
assert(!this.#closed, 'Protocol error: Connection closed.');
|
if (this.#closed) {
|
||||||
|
return Promise.reject(new Error('Protocol error: Connection closed.'));
|
||||||
|
}
|
||||||
return callbacks.create(method, options?.timeout ?? this.#timeout, id => {
|
return callbacks.create(method, options?.timeout ?? this.#timeout, id => {
|
||||||
const stringifiedMessage = JSON.stringify({
|
const stringifiedMessage = JSON.stringify({
|
||||||
method,
|
method,
|
||||||
|
Loading…
Reference in New Issue
Block a user