Skip to content

Commit

Permalink
fix: remove import cycle (#11227)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Oct 23, 2023
1 parent 60f1b78 commit 525f13c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
20 changes: 0 additions & 20 deletions packages/puppeteer-core/src/cdp/ExecutionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
PuppeteerURL,
SOURCE_URL_REGEX,
createEvaluationError,
debugError,
getSourcePuppeteerURLIfAvailable,
getSourceUrlComment,
isString,
Expand Down Expand Up @@ -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);
});
}
22 changes: 20 additions & 2 deletions packages/puppeteer-core/src/cdp/JSHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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);
});
}
3 changes: 2 additions & 1 deletion packages/puppeteer-core/src/cdp/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 525f13c

Please sign in to comment.