Skip to content
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

meta(eslint-config): Don't allow voiding Promises #9814

Merged
merged 12 commits into from
Dec 20, 2023

Conversation

lforst
Copy link
Member

@lforst lforst commented Dec 13, 2023

We should be a bit more strict about floating promises in the SDK. Right now we're just slapping void on all of them which is a bit like ts-ignore. Ideally, we are a bit more explicit about handling rejected promises or ignoring the lint rule with a description.

This pr turns off the "void" option of the lint rule so that we become more explicit.

@anonrig
Copy link
Contributor

anonrig commented Dec 14, 2023

@lforst Can you share an example?

Copy link
Contributor

github-actions bot commented Dec 18, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 75.39 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 66.79 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 60.39 KB (+0.06% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.39 KB (0%)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.04 KB (0%)
@sentry/browser - Webpack (gzipped) 21.69 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 72.79 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 64.51 KB (+0.02% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 30.71 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 22.77 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 202.36 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 92.28 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 67.34 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 33.62 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 67.17 KB (+0.06% 🔺)
@sentry/react - Webpack (gzipped) 21.72 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 83.93 KB (+0.05% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.57 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 16.35 KB (0%)

});
// This should never reject
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this._worker.postMessage('clear');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly, this can reject 😬

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alrighty, does this work? 06d041a

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea.
Not sure msyelf but wdyt about allowing voiding in tests?

@lforst
Copy link
Member Author

lforst commented Dec 19, 2023

Not sure msyelf but wdyt about allowing voiding in tests?

@Lms24 I had the same thought but for some reason I couldn't get the eslint filtering rules to properly apply so I just said "screw it im ignoring all of these"... Let me try again.

@lforst
Copy link
Member Author

lforst commented Dec 19, 2023

Ok I don't think this is is easily doable because eslintrcs look from the root and in "test packages" like e2e tests there are no test folders that we can match. Test folders and test files are already excluded from this rule. 

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I don't think this is is easily doable because eslintrcs look from the root and in "test packages" like e2e tests there are no test folders that we can match. Test folders and test files are already excluded from this rule.

makes sense, thx for trying!

packages/browser-integration-tests/utils/replayHelpers.ts Outdated Show resolved Hide resolved
packages/deno/src/integrations/globalhandlers.ts Outdated Show resolved Hide resolved
@@ -21,4 +21,5 @@ async function run(): Promise<void> {
}
}

void run();
// eslint-disable-next-line @typescript-eslint/no-floating-promises
run();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wdyt?

Suggested change
run();
(async () => { await run() })();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will still create a floating promise

@lforst lforst merged commit 7ace093 into develop Dec 20, 2023
95 checks passed
@lforst lforst deleted the lforst-dont-allow-voiding-promises branch December 20, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants