Skip to content

lsp: Fix 'Start with Hello World!' panic in SlintPad#11419

Open
tronical wants to merge 2 commits intomasterfrom
simon/slintpad-fix
Open

lsp: Fix 'Start with Hello World!' panic in SlintPad#11419
tronical wants to merge 2 commits intomasterfrom
simon/slintpad-fix

Conversation

@tronical
Copy link
Copy Markdown
Member

The slint/populate command handler called tokio::task::spawn_local, which
panics in the wasm LSP because no tokio LocalSet is installed there (only
native's main loop sets one up).

Introduce a common::spawn_local wrapper that routes to
wasm_bindgen_futures::spawn_local on wasm and tokio::task::spawn_local
on native, and forbid bare tokio::task::spawn_local in the lsp crate via
a clippy.toml disallowed-methods entry plus a crate-local
#![deny(clippy::disallowed_methods)] on the entry points.

Fixes #11416.

…anic

Reproduces #11416: clicking the "Start with Hello World!" code lens on an
empty buffer panics the wasm LSP because the slint/populate handler calls
tokio::task::spawn_local outside of a LocalSet.
@tronical tronical force-pushed the simon/slintpad-fix branch from 8dc3a68 to 0c24847 Compare April 17, 2026 08:43
Copy link
Copy Markdown
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

The way i've done it before would be to just call
crate::spawn_local(...) and have one implementation in wasm_main.rs and one in main.rs. But i get that this is conflicting with leon's change to put the lsp in a library with several runner.

Copy link
Copy Markdown
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

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

I like you started to use disallowed-methods

The slint/populate command handler called tokio::task::spawn_local, which
panics in the wasm LSP because no tokio LocalSet is installed there (only
native's main loop sets one up).

Introduce a `common::spawn_local` wrapper that routes to
`wasm_bindgen_futures::spawn_local` on wasm and `tokio::task::spawn_local`
on native, and forbid bare `tokio::task::spawn_local` in the lsp crate via
a clippy.toml disallowed-methods entry plus a crate-local
`#![deny(clippy::disallowed_methods)]` on the entry points.

Fixes #11416.
@tronical tronical force-pushed the simon/slintpad-fix branch from c7e9fac to 72d4e07 Compare April 17, 2026 09:00
@tronical tronical enabled auto-merge (rebase) April 17, 2026 09:17
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.

[SlintPad] "Start with hello world" panic: spawn_local called from outside of a task::LocalSet or runtime::LocalRuntime

2 participants