-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ci: fix callback in permissions.helper.ts for promise resolution #39390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ export const updatePermission = (permission: string, roles: string[]): Promise<v | |||||||||||||||||||||
| .send({ permissions: [{ _id: permission, roles }] }) | ||||||||||||||||||||||
| .expect('Content-Type', 'application/json') | ||||||||||||||||||||||
| .expect(200) | ||||||||||||||||||||||
| .end((err?: Error) => setTimeout(() => (!err && resolve()) || reject(err), 100)); | ||||||||||||||||||||||
| .end((err?: Error) => (!err && resolve()) || reject(err)); | ||||||||||||||||||||||
|
||||||||||||||||||||||
| .end((err?: Error) => (!err && resolve()) || reject(err)); | |
| .end((err?: Error) => | |
| setTimeout(() => { | |
| if (err) { | |
| reject(err); | |
| return; | |
| } | |
| resolve(); | |
| }, 100), | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/meteor/tests/data/permissions.helper.ts` at line 16, The helper
currently resolves immediately in the .end callback (the line with .end((err?:
Error) => (!err && resolve()) || reject(err))); which can race with backend
permission propagation (notifyOnPermissionChangedById is fire-and-forget).
Change the success branch so it does not call resolve() immediately: wait for
permission propagation (either poll the API/event that reflects permission
changes, await a helper like notifyOnPermissionChangedById confirmation, or add
a short retry/poll loop with timeout) and only call resolve() after propagation
is observed; keep reject(err) behavior unchanged.
Uh oh!
There was an error while loading. Please reload this page.