Skip to content

Conversation

@loewenheim
Copy link
Contributor

Pre-merge checklist

If you work at Sentry, you're able to merge your own PR without review, but please don't unless there's a good reason.

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs
  • PR was reviewed and approved by a member of the Sentry docs team

Description of changes

This warns users not to use macros like #[tokio::main] or #[actix_web::main] and explains how to manually write an "async" main function.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Extra resources

@loewenheim loewenheim requested a review from a team August 14, 2023 15:12
@vercel
Copy link

vercel bot commented Aug 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 16, 2023 8:38am

@loewenheim loewenheim self-assigned this Aug 14, 2023
Copy link
Contributor

@lizokm lizokm left a comment

Choose a reason for hiding this comment

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

Made some language tweaks, otherwise this looks good!


### Async main function

The Sentry client must be initialized before any async runtime is started or threads are spawned. Unfortunately, this makes it impossible to use macros such as `#[tokio::main]` or `#[actix_web::main]`, because they start the runtime first. Thus, instead of
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The Sentry client must be initialized before any async runtime is started or threads are spawned. Unfortunately, this makes it impossible to use macros such as `#[tokio::main]` or `#[actix_web::main]`, because they start the runtime first. Thus, instead of
The Sentry client must be initialized before any async runtime is started, otherwise threads will be spawned. This means you'll have to avoid using macros such as `#[tokio::main]` or `#[actix_web::main]`, because they start the runtime first. So rather than doing this:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, here my formulation was clearly ambiguous. I meant "The Sentry client must be initialized before (any async runtime is started or threads are spawned)".

How does

The Sentry client must be initialized before starting an async runtime or spawning threads.

sound?

Copy link
Contributor

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

this sounds very good.
If you want to be very explicit about whats going on, you can also explain the reasoning:

Each spawned thread inherits its Sentry Hub from the main thread. Thus, sentry::init has to happen on the main thread before any other threads are being spawned.

@loewenheim
Copy link
Contributor Author

@lizokm I've rewritten the paragraph under ### Async Main Function. What do you think?

@loewenheim loewenheim merged commit 25e79ce into master Aug 28, 2023
@loewenheim loewenheim deleted the fix/rust-async branch August 28, 2023 12:37
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants