fix(http-server-js): createPolicyChain returns Promise when policies are present#9917
Draft
fix(http-server-js): createPolicyChain returns Promise when policies are present#9917
Conversation
…specified Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix error when adding a global policy in http-server-js
fix(http-server-js): createPolicyChain returns Promise when policies are present
Mar 4, 2026
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.
createPolicyChaindiscarded the return value ofapplyPolicy, causing the returned function to returnundefinedinstead of aPromise. The generated router calls.catch()ondispatch(...), which threwTypeError: Cannot read properties of undefined (reading 'catch')whenever any policy was configured.Changes
src/helpers/router.ts: MadeapplyPolicyreturnPromise<void>. Base case wrapsout(...)inPromise.resolve()for proper error propagation. Recursive case usesnew Promisewith try/catch for synchronous policy errors, chaining downstream via.then(resolve, reject). The returned function now returns the promise fromapplyPolicy.generated-defs/helpers/router.ts: Regenerated to reflect the source change.test/router.test.ts: Added tests covering Promise return, policy execution order, error propagation fromout, synchronous policy throws, and request forwarding.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.