Skip to content

Commit f5cd428

Browse files
committed
docs(golang): say why the auth guest's block_on is wasm32-only
On native targets stack-auth now spawns a token refresh onto the current Tokio runtime. futures::executor::block_on provides none, so token and refresh in the auth guest would panic on the first refresh in a native build. Today only the wasm32 abi exports reach them, where stack-auth refreshes inline and block_on is sound. A cfg(target_arch = "wasm32") gate would leave their helpers dead on the native test build, so record the constraint where block_on is imported instead, before a native test finds the panic by accident.
1 parent 6503f06 commit f5cd428

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • languages/golang/auth/guest/src

‎languages/golang/auth/guest/src/auth.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ use std::cell::{Cell, RefCell};
66
use std::collections::HashMap;
77

88
use cts_common::Crn;
9+
// Sound on wasm32 only. There stack-auth runs a token refresh inline, so a
10+
// plain executor can drive `get_token` to completion. On a native target
11+
// stack-auth spawns the refresh onto the current Tokio runtime, and
12+
// `block_on` provides none, so the first refresh panics (and inside a
13+
// current-thread runtime it would block the thread the task needs). `token`
14+
// and `refresh` below are reached only through the wasm32 `abi` exports. A
15+
// native build, a test included, must not call them.
916
use futures::executor::block_on;
1017
use serde::Deserialize;
1118
use stack_auth::{

0 commit comments

Comments
 (0)