biomejs/biome · error
found a token with no parent
Error message
found a token with no parent
What it means
Panic in the Grit format-on-type handler (grit.rs:477). The handler calls token.parent() on the token found at the cursor; in rowan trees the root is a node, so tokens from token_at_offset always have a parent. This is a defensive assertion for a state (detached or token-rooted tree) the parser cannot produce.
Source
Thrown at crates/biome_service/src/file_handlers/grit.rs:477
// 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: GritSyntaxNode| node.kind().is_bogus())
{
return Ok(format_on_type_noop(offset));
}
let formatting_root = root_node
.ancestors()
.find(|node: &GritSyntaxNode| {
node.parent()
.is_some_and(|parent| parent.kind() == GritSyntaxKind::GRIT_ROOT)
})
.unwrap_or(root_node);
let printed =View on GitHub (pinned to 405dedb0ff)
Solutions
- Update to the latest Biome release
- Report a reproducer (document + keystroke) to https://github.com/biomejs/biome/issues if found
- Embedders: guard on-type formatting with catch_unwind and treat failure as no-op
Defensive patterns
Strategy: fallback
Try / catch
// LSP client - best-effort on-type formatting
try {
const edits = await client.sendRequest('textDocument/onTypeFormatted', params);
} catch {
// ignore: formatting is optional, typing must never block
} Prevention
- Wrap all optional formatting requests in best-effort error handling
- Pin a known-good Biome version
- Report reproductions upstream; this arm should be unreachable in practice
When it happens
Trigger: Not reachable via normal LSP requests; only a detached token or token-rooted tree would trigger it.
Common situations: Essentially theoretical; surfacing only with hand-constructed trees or internal API misuse.
Related errors
- found a token with no parent
- found a token with no parent
- empty file
- 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/e175d80d29108244.
Report an issue: GitHub.