Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Handle inspector crash #70

Merged
merged 6 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/js-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
git init -b main
git add -A
git commit -m 'Auto-build Javascript files'
git push -f https://ulixee:${{ env.GH_TOKEN }}@github.com/ulixee/unblocked.git main:${{ github.ref_name }}-built-js
git push -f https://ulixee:${{ env.GH_TOKEN }}@github.com/${{github.repository}}.git main:${{ github.ref_name }}-built-js
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 8 additions & 7 deletions agent/main/lib/Browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Protocol from 'devtools-protocol';
import { TypedEventEmitter } from '@ulixee/commons/lib/eventUtils';
import { assert } from '@ulixee/commons/lib/utils';

Check warning on line 3 in agent/main/lib/Browser.ts

View workflow job for this annotation

GitHub Actions / Test node-18, ubuntu-latest, latest

'assert' is defined but never used. Allowed unused vars must match /^_/u
import Log from '@ulixee/commons/lib/Logger';
import IBrowserEngine from '@ulixee/unblocked-specification/agent/browser/IBrowserEngine';
import IBrowserUserConfig from '@ulixee/unblocked-specification/agent/browser/IBrowserUserConfig';
Expand Down Expand Up @@ -64,7 +64,7 @@
private preferencesInterceptor?: DevtoolsPreferences;

private browserContextCreationHooks: IBrowserContextHooks;
private connectOnlyToPageTargets: { [targetId: string]: IPageCreateOptions };
private connectOnlyToPageTargets?: { [targetId: string]: IPageCreateOptions };

private get defaultBrowserContext(): BrowserContext {
return this.browserContextsById.get(undefined);
Expand Down Expand Up @@ -380,18 +380,19 @@
private onAttachedToTarget(event: Protocol.Target.AttachedToTargetEvent): void {
const { targetInfo, sessionId } = event;

assert(targetInfo.browserContextId, `targetInfo: ${JSON.stringify(targetInfo, null, 2)}`);

this.browserContextsById
.get(targetInfo.browserContextId)
?.targetsById.set(targetInfo.targetId, targetInfo);

const isDevtoolsPanel = targetInfo.url.startsWith('devtools://devtools');
const isContextLess = !targetInfo.browserContextId;
if (
event.targetInfo.type === 'page' &&
!isDevtoolsPanel &&
this.connectOnlyToPageTargets &&
!this.connectOnlyToPageTargets[targetInfo.targetId]
isContextLess || (
event.targetInfo.type === 'page' &&
!isDevtoolsPanel &&
this.connectOnlyToPageTargets &&
!this.connectOnlyToPageTargets[targetInfo.targetId]
)
) {
if (this.debugLog) {
log.stats('Not connecting to target', { event, sessionId: null });
Expand Down
Loading