Skip to content

Conversation

@mydea
Copy link
Member

@mydea mydea commented Dec 20, 2023

Refactors deno integrations to functional syntax.

@mydea mydea requested review from AbhiPrasad and timfish December 20, 2023 11:31
@mydea mydea self-assigned this Dec 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Dec 20, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 75.43 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 66.82 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 60.42 KB (0%)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.43 KB (0%)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 30.07 KB (0%)
@sentry/browser - Webpack (gzipped) 21.73 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 72.83 KB (-0.01% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 64.52 KB (-0.05% 🔽)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 30.71 KB (-0.13% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped) 22.77 KB (-0.15% 🔽)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 202.42 KB (-0.03% 🔽)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 92.34 KB (-0.07% 🔽)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 67.39 KB (-0.09% 🔽)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 33.67 KB (+0.05% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 67.2 KB (0%)
@sentry/react - Webpack (gzipped) 21.76 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 83.97 KB (0%)
@sentry/nextjs Client - Webpack (gzipped) 48.6 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 16.38 KB (0%)

@mydea mydea force-pushed the fn/deno-integrations branch from 8b2b578 to 2d20567 Compare December 20, 2023 15:44
}

async function cronCalled(): Promise<void> {
if (getClient() !== client) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@timfish checking this here to make sure this is only applies if this is the current client, otherwise it may send a monitor to a different client I guess.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Part of me was thinking that you might still need to call fn() rather than return but now I'm not sure.

I'm struggling to get my head around how it'll all behave if wrapped multiple times 🤔

Copy link
Member

Choose a reason for hiding this comment

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

This patch should be done once, not per client, because it proxies the global Deno.cron function, but we still need the getClient() !== client so that monitors from clients with the integration get sent.

Can we check if client has integration installed and check accordingly?

We might have to audit all of our integrations for this behaviour now that I think about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've actually rewritten most of them this way, but you're right, it makes more sense this way here too - will follow the same as I did in other PRs already!

@mydea mydea force-pushed the fn/deno-integrations branch from 2d20567 to b649c94 Compare December 20, 2023 16:21
@mydea mydea force-pushed the fn/deno-integrations branch from b649c94 to ad1ec1e Compare December 21, 2023 08:29
const denoCronIntegration = (() => {
return {
name: INTEGRATION_NAME,
setupOnce() {
Copy link
Member Author

Choose a reason for hiding this comment

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

@AbhiPrasad / @timfish , ok, hopefully final refactor here - now this registers once in setupOnce, and registers the client in setup, which we check for in here!

@mydea mydea merged commit 12a4fce into develop Dec 21, 2023
@mydea mydea deleted the fn/deno-integrations branch December 21, 2023 11:35

async function cronCalled(): Promise<void> {
if (SETUP_CLIENTS.includes(getClient() as Client)) {
return;
Copy link
Member

Choose a reason for hiding this comment

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

Don't we still want to call fn here?


const INTEGRATION_NAME = 'DenoCron';

const SETUP_CLIENTS: Client[] = [];
Copy link
Member

Choose a reason for hiding this comment

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

This means that clients dont get GC'd - I wonder if we should track with a WeakMap instead?

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.

4 participants