Skip to content

Commit d02923a

Browse files
jackwenerclaude
andcommitted
fix: allow browser:false commands to run without page after lazy-load
The C2 fix in PR #337 added a null-page guard after lazy-loading TS modules, but it threw unconditionally — breaking all browser:false commands (bloomberg, apple-podcasts, google, yollomi, etc.) that use func() with a null page. Guard now checks updated.browser !== false. Also fixes apple-podcasts top E2E flake: when the command times out on CI, stderr is empty and the guard didn't catch it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f6466db commit d02923a

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/execution.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ async function runCommand(
9999
// After loading, the module's cli() call will have updated the registry.
100100
const updated = getRegistry().get(fullName(cmd));
101101
if (updated?.func) {
102-
if (!page) throw new CommandExecutionError(`Command ${fullName(cmd)} requires a browser session but none was provided`);
103-
return updated.func(page, kwargs, debug);
102+
if (!page && updated.browser !== false) {
103+
throw new CommandExecutionError(`Command ${fullName(cmd)} requires a browser session but none was provided`);
104+
}
105+
return updated.func(page as IPage, kwargs, debug);
104106
}
105107
if (updated?.pipeline) return executePipeline(page, updated.pipeline, { args: kwargs, debug });
106108
}

tests/e2e/public-commands.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function isExpectedChineseSiteRestriction(code: number, stderr: string): boolean
1616

1717
function isExpectedApplePodcastsRestriction(code: number, stderr: string): boolean {
1818
if (code === 0) return false;
19-
return /Error \[FETCH_ERROR\]: (Charts API HTTP \d+|Unable to reach Apple Podcasts charts)/.test(stderr);
19+
return /Error \[FETCH_ERROR\]: (Charts API HTTP \d+|Unable to reach Apple Podcasts charts)/.test(stderr)
20+
|| stderr === ''; // timeout killed the process before any output
2021
}
2122

2223
function isExpectedGoogleRestriction(code: number, stderr: string): boolean {

0 commit comments

Comments
 (0)