-
-
Notifications
You must be signed in to change notification settings - Fork 827
Log unhandled promise rejections in the rageshake #12028
Log unhandled promise rejections in the rageshake #12028
Conversation
Not sure what's the best way to test this. Is there a way to check if something got logged? |
You could call |
It looks like Jest installs its own handler for unhandled rejections, which interferes with the handler that I've installed. I tried writing a test as: import { init } from "../src/rageshake/rageshake";
import { sleep } from "matrix-js-sdk/src/utils";
describe("rageshake", () => {
it("should log unhandled promise rejections", async () => {
await init(false);
new Promise((resolve, reject) => { reject("foo"); });
await sleep(2000); // wait for the promise to reject
const logs = global.mx_rage_logger.flush();
expect(logs).toMatch(/Unhandled promise rejection: foo/);
});
}); And get the following output from Jest:
So you can see that Jest handles the rejection. Any suggestions for how to get around this? I did try in Element Web, and it does log unhandled promise rejections: |
Expect the throw
(or similar; untested) Though I guess this may also handle it which means your handler won't fire either. urgh |
Since Jest doesn't want to let me test the code, and none of the other rageshake code has tests either, does anyone mind if I bypass the testing quality gate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Fixes element-hq/element-web#26639
Checklist
This change is marked as an internal change (Task), so will not be included in the changelog.