biomejs/biome · error
found a token with no parent
Error message
found a token with no parent
What it means
Panic in the GraphQL format-on-type handler (graphql.rs:540). After finding the token at the offset, the handler calls token.parent(); tokens returned by token_at_offset on a parsed rowan tree always have a parent node because the tree root is a node. This panic is a defensive assertion for a detached/token-rooted tree that the normal parse path cannot produce.
Source
Thrown at crates/biome_service/src/file_handlers/graphql.rs:540
// File is empty, do nothing
TokenAtOffset::None => panic!("empty file"),
TokenAtOffset::Single(token) => token,
// The cursor should be right after the closing character that was just typed,
// select the previous token as the correct one
TokenAtOffset::Between(token, _) => token,
};
if token.text_trimmed_range().end() != offset {
return Ok(format_on_type_noop(offset));
}
if !matches_on_type_char(token.text_trimmed()) {
return Ok(format_on_type_noop(offset));
}
let root_node = match token.parent() {
Some(node) => node,
None => panic!("found a token with no parent"),
};
if root_node
.ancestors()
.any(|node: GraphqlSyntaxNode| node.kind().is_bogus())
{
return Ok(format_on_type_noop(offset));
}
let formatting_root = root_node
.ancestors()
.find(|node: &GraphqlSyntaxNode| {
node.parent()
.is_some_and(|parent| parent.kind() == GraphqlSyntaxKind::GRAPHQL_ROOT)
})
.unwrap_or(root_node);
let printed = biome_graphql_formatter::format_range(View on GitHub (pinned to 405dedb0ff)
Solutions
- Update to the latest Biome release
- File an issue with the exact document and keystroke if you can reproduce it (https://github.com/biomejs/biome/issues)
- If embedding biome_service, wrap on-type format calls in catch_unwind and degrade to no formatting
Defensive patterns
Strategy: fallback
Try / catch
// LSP client - ignore a failed on-type format request
try {
await client.sendRequest('textDocument/onTypeFormatted', params);
} catch {
// no-op: keep typing responsive, do not surface the error
} Prevention
- Never make editor input depend on the success of onTypeFormatted
- Pin a stable Biome release for editor integrations
- File a bug with the exact buffer if this defensive panic ever fires
When it happens
Trigger: Not reachable through normal editor traffic; would require a detached token or a token-rooted syntax tree, neither of which tree.token_at_offset produces.
Common situations: Practically never observed; only plausible with hand-built trees in tests or after parser internals changed.
Related errors
- found a token with no parent
- empty file
- found a token with no parent
- found a token with no parent
- found a token with no parent
AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20).
Data as JSON: /api/errors/6d6e89de4a38628e.
Report an issue: GitHub.