mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
fix(sse): remove duplicate const settings in handleChatCore
handleChatCore declared `const settings = cachedSettings ?? await
getCachedSettings()` twice in the same function scope — the consolidated
"fetch once, reuse" const near the top, plus a duplicate added alongside the
per-key stream-default-mode feature. esbuild/tsx rejected the same-scope
redeclaration ("The symbol 'settings' has already been declared"), which made
every unit test that imports chatCore fail to transform and broke the
production build.
Remove the duplicate; reuse the earlier consolidated `settings`. Add an
import-guard regression test.
This commit is contained in:
@@ -59,6 +59,12 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- **sse/chatCore:** remove a duplicate `const settings` declaration in
|
||||
`handleChatCore` (introduced alongside the per-key stream-default-mode
|
||||
feature). The same-scope redeclaration made esbuild/tsx fail with
|
||||
"The symbol 'settings' has already been declared", which turned every unit
|
||||
test that imports chatCore red and broke the production build. The earlier
|
||||
consolidated `settings` const is now reused.
|
||||
- **db/migrations:** resolve a `077` migration version collision
|
||||
(`077_api_key_stream_default_mode.sql` vs `077_quota_pools.sql`) that made
|
||||
`getMigrationFiles()` throw and blocked `getDbInstance()` at startup (app would
|
||||
|
||||
@@ -2151,7 +2151,10 @@ export async function handleChatCore({
|
||||
userAgent: streamUserAgent,
|
||||
streamDefaultMode: apiKeyInfo?.streamDefaultMode,
|
||||
});
|
||||
const settings = cachedSettings ?? (await getCachedSettings());
|
||||
// `settings` is already consolidated once near the top of handleChatCore
|
||||
// (the "fetch once, reuse" const). A second `const settings` here was a
|
||||
// duplicate same-scope declaration that broke the esbuild/tsx transform
|
||||
// ("settings has already been declared") and the production build. Reuse it.
|
||||
credentials = applyCodexGlobalFastServiceTier(provider, credentials, settings, {
|
||||
model: requestedModel,
|
||||
body: body && typeof body === "object" ? (body as Record<string, unknown>) : null,
|
||||
|
||||
23
tests/unit/chatcore-imports-cleanly.test.ts
Normal file
23
tests/unit/chatcore-imports-cleanly.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Regression guard: `open-sse/handlers/chatCore.ts` must transform/compile.
|
||||
*
|
||||
* `handleChatCore` declared `const settings` twice in the same function scope
|
||||
* (a "fetch once, reuse" const near the top + a duplicate added by the per-key
|
||||
* stream-default-mode feature). esbuild/tsx rejected it with
|
||||
* "The symbol 'settings' has already been declared", which turned EVERY test
|
||||
* that imports chatCore red and broke the production build.
|
||||
*
|
||||
* Importing the module forces the transform; if the duplicate declaration
|
||||
* returns, this import throws and the test fails loudly.
|
||||
*/
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
test("chatCore.ts imports without a duplicate-declaration transform error", async () => {
|
||||
const mod = await import("../../open-sse/handlers/chatCore.ts");
|
||||
assert.equal(
|
||||
typeof mod.handleChatCore,
|
||||
"function",
|
||||
"handleChatCore must be importable (no duplicate `const settings` in scope)"
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user