Repository navigation
fix(scripting): preserve variables set in req.onFail - #8575
Conversation
WalkthroughRequest ChangesonFail variable propagation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ScriptRuntime
participant NetworkFailurePath
participant executeRequestOnFailHandler
participant sendVariableUpdates
ScriptRuntime->>NetworkFailurePath: expose request failure result
NetworkFailurePath->>executeRequestOnFailHandler: handle failure
executeRequestOnFailHandler-->>NetworkFailurePath: return script result
NetworkFailurePath->>sendVariableUpdates: forward variable mutations
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bruno-electron/tests/network/execute-request-error-handler.spec.js`:
- Around line 40-54: Add IPC-level regression tests for the registered
network-failure paths, covering both standalone and runner requests rather than
only executeRequestOnFailHandler. Invoke each failure path and assert that the
renderer receives runtime, environment, and global-environment update events
with the expected data.
In `@packages/bruno-js/tests/runtime.spec.js`:
- Around line 124-145: Add QuickJS coverage to the “should return variable
updates made in req.onFail” test by running the same script and handler-result
assertions with a ScriptRuntime configured as “quickjs”, while preserving the
existing NodeVM coverage.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 03fdb565-b1c1-4b1d-8e8e-0c2e135f016f
📒 Files selected for processing (4)
packages/bruno-electron/src/ipc/network/index.jspackages/bruno-electron/tests/network/execute-request-error-handler.spec.jspackages/bruno-js/src/runtime/script-runtime.jspackages/bruno-js/tests/runtime.spec.js
…l-variable-updates
be7e2ed
into
usebruno:fix/persist-on-fail-variable-updates
|
Hi, this PR is now merged to a feature branch which will be reviewed and merged to main. This is planned to be released in v4.2.0, which is planned to go out in September. We'll update here when a nightly build is available. Thanks for your contribution! |
|
Thanks for the update and for getting this merged! I appreciate the review and the release timeline. I’ll be happy to verify the fix once a nightly build is available. |
* fix(scripting): preserve variables set in onFail * test(scripting): cover onFail variable propagation --------- Co-authored-by: Elon <[email protected]>
* fix(scripting): preserve variables set in onFail * test(scripting): cover onFail variable propagation --------- Co-authored-by: Elon <[email protected]>
Description
Variables updated with
bru.setVar(),bru.setEnvVar(), orbru.setGlobalEnvVar()insidereq.onFail()were updated in the script runtime but were not forwarded to the renderer after the handler completed.Fixes #8569.
This change:
req.onFail()runsValidation
node --experimental-vm-modules ../../node_modules/jest/bin/jest.js tests/runtime.spec.js --runInBand(34 passed)HOME=/tmp/bruno-jest-home npm run test --workspace=packages/bruno-electron -- tests/network/execute-request-error-handler.spec.js -t "should return the result" --runInBandnpm run lint -- packages/bruno-js/src/runtime/script-runtime.js packages/bruno-js/tests/runtime.spec.js packages/bruno-electron/src/ipc/network/index.js packages/bruno-electron/tests/network/execute-request-error-handler.spec.jsThe full Electron test file contains existing environment-dependent DNS and timeout assertions. In this environment, one assertion receives
EPERMin the sandbox and the DNS assertion receives a TLS disconnect outside it; the focused regression test passes.Summary by CodeRabbit
onFail) handlers, including updates to runtime and environment variables.onFailhandler return values and that variable updates are correctly returned and applied.