fix: remove import cycle (#11227)

This commit is contained in:
Alex Rudenko 2023-10-23 11:20:04 +02:00 committed by GitHub
parent 60f1b788a6
commit 525f13cd18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 23 deletions

View File

@ -26,7 +26,6 @@ import {
PuppeteerURL,
SOURCE_URL_REGEX,
createEvaluationError,
debugError,
getSourcePuppeteerURLIfAvailable,
getSourceUrlComment,
isString,
@ -400,22 +399,3 @@ export function createCdpHandle(
}
return new CdpJSHandle(realm, remoteObject);
}
/**
* @internal
*/
export async function releaseObject(
client: CDPSession,
remoteObject: Protocol.Runtime.RemoteObject
): Promise<void> {
if (!remoteObject.objectId) {
return;
}
await client
.send('Runtime.releaseObject', {objectId: remoteObject.objectId})
.catch(error => {
// Exceptions might happen in case of a page been navigated or closed.
// Swallow these since they are harmless and we don't leak anything in this case.
debugError(error);
});
}

View File

@ -18,10 +18,9 @@ import type {Protocol} from 'devtools-protocol';
import type {CDPSession} from '../api/CDPSession.js';
import {JSHandle} from '../api/JSHandle.js';
import {valueFromRemoteObject} from '../common/util.js';
import {debugError, valueFromRemoteObject} from '../common/util.js';
import type {CdpElementHandle} from './ElementHandle.js';
import {releaseObject} from './ExecutionContext.js';
import type {IsolatedWorld} from './IsolatedWorld.js';
/**
@ -98,3 +97,22 @@ export class CdpJSHandle<T = unknown> extends JSHandle<T> {
return this.#remoteObject;
}
}
/**
* @internal
*/
export async function releaseObject(
client: CDPSession,
remoteObject: Protocol.Runtime.RemoteObject
): Promise<void> {
if (!remoteObject.objectId) {
return;
}
await client
.send('Runtime.releaseObject', {objectId: remoteObject.objectId})
.catch(error => {
// Exceptions might happen in case of a page been navigated or closed.
// Swallow these since they are harmless and we don't leak anything in this case.
debugError(error);
});
}

View File

@ -73,12 +73,13 @@ import {Coverage} from './Coverage.js';
import type {DeviceRequestPrompt} from './DeviceRequestPrompt.js';
import {CdpDialog} from './Dialog.js';
import {EmulationManager} from './EmulationManager.js';
import {createCdpHandle, releaseObject} from './ExecutionContext.js';
import {createCdpHandle} from './ExecutionContext.js';
import {FirefoxTargetManager} from './FirefoxTargetManager.js';
import type {CdpFrame} from './Frame.js';
import {FrameManager, FrameManagerEvent} from './FrameManager.js';
import {CdpKeyboard, CdpMouse, CdpTouchscreen} from './Input.js';
import {MAIN_WORLD} from './IsolatedWorlds.js';
import {releaseObject} from './JSHandle.js';
import type {Credentials, NetworkConditions} from './NetworkManager.js';
import type {CdpTarget} from './Target.js';
import type {TargetManager} from './TargetManager.js';