Skip to content

Commit

Permalink
fix(cdp): throw on closed connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning00Blade committed Apr 26, 2024
1 parent 069606e commit 763facc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/puppeteer-core/src/cdp/Connection.ts
Expand Up @@ -18,6 +18,7 @@ import type {ConnectionTransport} from '../common/ConnectionTransport.js';
import {debug} from '../common/Debug.js';
import {TargetCloseError} from '../common/Errors.js';
import {EventEmitter} from '../common/EventEmitter.js';
import {assert} from '../util/assert.js';
import {createProtocolErrorMessage} from '../util/ErrorLike.js';

import {CdpCDPSession} from './CDPSession.js';
Expand Down Expand Up @@ -117,6 +118,8 @@ export class Connection extends EventEmitter<CDPSessionEvents> {
sessionId?: string,
options?: CommandOptions
): Promise<ProtocolMapping.Commands[T]['returnType']> {
assert(!this.#closed, 'Protocol error: Connection closed.');

return callbacks.create(method, options?.timeout ?? this.#timeout, id => {
const stringifiedMessage = JSON.stringify({
method,
Expand Down

0 comments on commit 763facc

Please sign in to comment.