fix(opencode): suppress vertex metadata lookup warning
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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")
|
||||
})
|
||||
Reference in New Issue
Block a user