fix(opencode): suppress vertex metadata lookup warning
This commit is contained in:
parent
922903e410
commit
5852e79ec6
4 changed files with 25 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import "./init-projectors"
|
||||
import "@/util/warning"
|
||||
|
||||
import { NodeHttpServer } from "@effect/platform-node"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import path from "path"
|
||||
import os from "os"
|
||||
import "@/util/warning"
|
||||
import { SessionID, MessageID, PartID } from "./schema"
|
||||
import { MessageV2 } from "./message-v2"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
|
|
|
|||
10
packages/opencode/src/util/warning.ts
Normal file
10
packages/opencode/src/util/warning.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
const emitWarning = process.emitWarning.bind(process)
|
||||
|
||||
// Google ADC checks the metadata service during local Vertex authentication.
|
||||
// That expected miss should not write directly over the interactive UI.
|
||||
process.emitWarning = ((...args: Parameters<typeof process.emitWarning>) => {
|
||||
const type = typeof args[1] === "string" ? args[1] : args[1]?.type
|
||||
const name = type ?? (args[0] instanceof Error ? args[0].name : undefined)
|
||||
if (name === "MetadataLookupWarning") return
|
||||
emitWarning(...args)
|
||||
}) as typeof process.emitWarning
|
||||
13
packages/opencode/test/util/warning.test.ts
Normal file
13
packages/opencode/test/util/warning.test.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { expect, test } from "bun:test"
|
||||
import { Process } from "@/util/process"
|
||||
|
||||
test("suppresses metadata lookup warnings without hiding other warnings", async () => {
|
||||
const out = await Process.run([
|
||||
process.execPath,
|
||||
"-e",
|
||||
'await import("./src/util/warning.ts"); process.emitWarning("metadata", "MetadataLookupWarning"); process.emitWarning("visible", "VisibleWarning")',
|
||||
])
|
||||
|
||||
expect(out.stderr.toString()).not.toContain("MetadataLookupWarning")
|
||||
expect(out.stderr.toString()).toContain("VisibleWarning: visible")
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue