Skip to content

fix(ts): close the hook timeout template literal in hooks.ts - #1056

Merged
NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
sathariels:fix/ts-hooks-timeout-literal
Oct 10, 2026
Merged

NandhaKishorM merged 1 commit into
NandhaKishorM:mainfrom
sathariels:fix/ts-hooks-timeout-literal

Conversation

@sathariels

Copy link
Copy Markdown
Contributor

Summary

laya-ts/src/hooks.ts doesn't parse on main. In runWithTimeout, the hook timeout Error message opens with a backtick but closes with a double quote (added in 9478652). Vitest fails with [PARSE_ERROR] Expected , or ) but found Identifier around line 366, and 22 of the 34 TypeScript test files fail to load, so the TypeScript (node20/node22) check is red on main and on every open PR.

This closes the template literal with a backtick. The message text is unchanged: hook ${operationName} timed out after ${timeoutMs}ms.

Once it parsed, tsc --noEmit flagged three more spots in that same timeout code, so I fixed those too:

  • dispatch's opts type now includes hook?: Hook, which it already reads.
  • The hook result goes through Promise.resolve(...) before runWithTimeout, since a hook method can return void.
  • hooksTimeout is narrowed with ?? null before converting to milliseconds.

Tests

  • Node 22, in laya-ts: npm ci && npm test -- --run, 34 files and 654 tests passed (includes the type tests)
  • npx tsc --noEmit passes

The timeout Error in runWithTimeout was opened with a backtick and
closed with a double quote, so vitest could not parse hooks.ts
(introduced in 9478652).

The same change also failed tsc --noEmit: dispatch's opts type omitted
hook, runWithTimeout was passed a sync-or-async hook result, and
hooksTimeout was multiplied before undefined was narrowed away.

Co-authored-by: Nithilan Kumaran <sathariels@users.noreply.github.com>
@NandhaKishorM
NandhaKishorM merged commit ba12c76 into NandhaKishorM:main Oct 10, 2026
38 checks passed
@NandhaKishorM

Copy link
Copy Markdown
Owner

Merged, and thank you for catching this. You were right that main was broken, and I am the one who broke it.

Confirmed before fixing: laya-ts/src/hooks.ts line 351 opened a template literal with a backtick and closed it with a double quote, and 22 of the 34 TypeScript test files failed to load as a result. That came in through 9478652, which is #1032's commit, which I merged in the 0.4.1 pass. My gate for that pass was scripts/test_suites.py, which is Python only, so I never ran vitest and never saw it. The TypeScript lane has been red on main and on every open PR since.

That is a real gap in my own verification and I have no excuse for it: I ran the TypeScript suite in earlier passes and did not in that one.

On the merge itself, I took a different resolution than your diff, and you should check I got it right. Two of the three spots had already been fixed, better, by a drive-along commit in #1053 (acc23b0c, branched off someone's fix branch), and your branch conflicted with it:

Your third fix, the hook?: Hook field on the dispatch opts type, is present from the same commit.

So the parse fix is in and the tree is green: 34 files, 654 tests, tsc --noEmit clean. If you think the Promise<void> signature is wrong and runWithTimeout should return the hook's value, that is a reasonable position and worth its own PR, but it is a contract change rather than a syntax fix.

One other thing worth knowing: tests/identifier-complexity.test.ts fails intermittently under the full parallel run with a wall-clock ratio assertion ("4x the input costs under 8x the time", measured 10.6x). It passes 3 of 3 in isolation. That is load-sensitivity on a busy machine, not a regression, and it is the same class as the BPE timeout that needed an explicit bound a few releases ago.

NandhaKishorM added a commit that referenced this pull request Oct 10, 2026
14 pull requests from 8 contributors.

* the TypeScript tree parses again: an unterminated template literal shipped in
  0.4.1 and stopped 22 of 34 test files loading (#1056)
* x_jev_confidence on /v1/systemone, computed locally (#1066, #302)
* a narrowed shortlist drops option_order with a warning instead of failing (#1063)
* registering a name one edit from a built-in warns (#1055, #919)
* compose forwards four knobs the runtime already read (#1053, #1054)
* Java Router.predictBatch and Shortlist.predictTournament (#1060, #1061)
* teacher-agreement evals, with the self-agreement ceiling (#1071, #919)

Security: no malicious content found; the audit is recorded locally.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

3 participants