denoland/deno · error · Error
Empty node
Error message
Empty node
What it means
`Empty node` is a defensive invariant check in popSelector (cli/js/40_lint_selector.js): after confirming the parent selector group is non-empty, it reads the group's last node and throws if it is undefined. Logically the preceding length check makes this unreachable — a non-empty array always has a last element — so seeing it means internal parser state was corrupted by a malformed selector key, not anything actionable in your own code.
Source
Thrown at cli/js/40_lint_selector.js:778
/**
* @param {Selector[]} result
* @param {Selector[]} stack
*/
function popSelector(result, stack) {
const sel = /** @type {Selector} */ (stack.pop());
if (stack.length === 0) {
result.push(sel);
stack.push([]);
} else {
const prev = /** @type {Selector} */ (stack.at(-1));
if (prev.length === 0) {
throw new Error(`Empty selector`);
}
const node = prev.at(-1);
if (node === undefined) {
throw new Error(`Empty node`);
}
if (node.type === PSEUDO_NTH_CHILD) {
node.of = sel;
} else if (
node.type === PSEUDO_HAS || node.type === PSEUDO_IS ||
node.type === PSEUDO_NOT
) {
node.selectors.push(sel);
} else {
throw new Error(`Multiple selectors not allowed here`);
}
}
}
const TRUE_FN = () => {
return true;
};View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Minimize the visitor key that triggers it and simplify the selector (drop pseudo-clauses and attribute parts one by one).
- Move complex matching logic out of the selector and into JavaScript inside the visitor callback.
- Report the minimal reproducible key to the Deno repository, since this guard should not be reachable.
Defensive patterns
Strategy: validation
Prevention
- Treat this error as a parser-bug signal, not a fixable input error.
- Reproduce with the smallest visitor key possible and report it upstream with the exact selector string.
When it happens
Trigger: Effectively unreachable through normal selector syntax; it guards against an inconsistent parser state after a malformed or degenerate visitor key was partially parsed.
Common situations: Almost always a latent parser edge case rather than a user mistake; if reproducible, the value is a bug report against the selector engine.
Related errors
- Empty selector
- Multiple selectors not allowed here
- Unknown attribute operator: '${s}'
- Expected token '${token}', but got '${this.token}'.\n\n${thi
- Invalid RegExp pattern: ${raw}
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/ef416bd7e1300bc5.
Report an issue: GitHub.