-
Notifications
You must be signed in to change notification settings - Fork 342
Open
Labels
Milestone
Description
Describe the bug
When using http-server-js with a custom global policy, an error is thrown.
const policy: Policy = async (ctx, next) => {
next();
}
const router = createDemoServiceRouter({...}, { policies: [policy] });
// ...this will always throw TypeError: Cannot read properties of undefined (reading 'catch')
Reproduction
Here is a repo with the reproduction of each case https://github.com/benjlevesque/repro-typespec-issues/blob/main/policy.test.ts
Resolution lead
The bug seems to be in the implementation of createPolicyChain, which does not return a Promise when at least one Policy is specified.
Adding async or returning Promise.resolve fixes the problem
Reactions are currently unavailable