Repository navigation
fix(function): pass url into stub-page templates - #939
Merged
Merged
Conversation
extendPage can skip Chromium while the snippet still destructures url. The no-page and full-browser wrappers already forwarded the target URL; the stub-page wrapper dropped it, so url was undefined and new URL(path, url) threw.
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
After
extendPage(#937) and passingurlinto user functions (#935), a snippet that only uses stubpagemethods plus the requesturlskipped Chromium and receivedurl: undefined.Concrete trigger:
with
extendPage: { html: '<h1>cached</h1>' }.new URL('/robots.txt', undefined)throws, so the function fails. Returningurlitself silently producedundefined.The documented contract is that every function receives the target
url. The no-page and full-browser wrappers already forwarded it; the stub-page wrapper did not.Root cause
packages/function/src/template.jsbuilt the stub-page call as{ page, response, ...rest }.urlis the wrapper's first argument and is stripped fromoptsbeforerestis formed, so it never reached the user function.Fix
Pass
urlthe same way as the other two wrappers:{ page, response, ...rest, url }so the target URL wins over anyopts.url.Validation
opts.urllosing to the target URL.extendPageintegration test that destructures bothpageandurlwith Chromium disabled.ava test/template.js test/extend-page.js: 29 passed.Note
Low Risk
Single-line template fix aligning stub-page behavior with existing wrappers; tests lock in the contract with no auth or data-handling changes.
Overview
Fixes a gap in the stub-page code path (when
extendPagestubs satisfy allpageusage so Chromium is skipped): user functions now receive the requesturlin the invocation args, matching the no-page and full-browser wrappers.The generated wrapper call changes from
{ page, response, ...rest }to{ page, response, ...rest, url }, so the wrapper’s first-argument target URL is available even though it is not part ofopts/rest. Targeturlstill wins overopts.url.Adds template coverage for stub-page
urlforwarding and precedence, plus anextendPageintegration test that destructures{ page, url }without starting a browser.Reviewed by Cursor Bugbot for commit 613fff5. Bugbot is set up for automated code reviews on this repo. Configure here.