Uh oh!
There was an error while loading. Please reload this page.
Fix: JSONResponse helper to preserve original onResponse behavior (Fixes #5042) - #5106
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the JSONResponse helper where setting the onResponse handler was overriding any existing custom onResponse handler in the user's configuration. The fix preserves the original onResponse behavior by wrapping it instead of replacing it.
Key changes:
- Preserve existing onResponse handlers by storing and calling the original function
- Maintain backward compatibility while fixing the override issue
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
kobenguyent
commented
Aug 24, 2025
Please add tests if that's possible. Thanks. |
myrepojuly
commented
Aug 24, 2025
@kobenguyent - I’ve added tests under ./test/unit/helper/, but some existing tests are failing, and I can’t push. |
kobenguyent
commented
Aug 24, 2025
@myrepojuly i guess that's fine as we would run tests on GitHub anyway. |
myrepojuly
commented
Aug 24, 2025
@kobenguyent - thank you.. Added the unit tests... |
Uh oh!
There was an error while loading. Please reload this page.
Motivation/Description of the PR
The current implementation overrides any custom onResponse handler that may have already been set in the user's configuration, causing their logic to be lost.
Suggested Fix:
Preserve the original onResponse handler by wrapping it, rather than replacing it:
onResponseprovided in config does not work #5042Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test)