From 9466531e858ffe184ad22651a8f67999398f8a55 Mon Sep 17 00:00:00 2001 From: media <69737851+sm-bean@users.noreply.github.com> Date: Thu, 27 Jun 2024 15:37:54 +0100 Subject: [PATCH] removes unnecessary wrangler tail warning against resetting durable object (#6160) * removes unnecessary wrangler tail warning against resetting durable object * removes commented out code --- .changeset/tender-boxes-confess.md | 7 ++++++ packages/wrangler/src/__tests__/tail.test.ts | 19 +-------------- packages/wrangler/src/tail/index.ts | 25 -------------------- 3 files changed, 8 insertions(+), 43 deletions(-) create mode 100644 .changeset/tender-boxes-confess.md diff --git a/.changeset/tender-boxes-confess.md b/.changeset/tender-boxes-confess.md new file mode 100644 index 000000000000..56f926b0d254 --- /dev/null +++ b/.changeset/tender-boxes-confess.md @@ -0,0 +1,7 @@ +--- +"wrangler": patch +--- + +fix: removes unnecessary wrangler tail warning against resetting durable object + +fixes https://jira.cfdata.org/browse/STOR-3318 diff --git a/packages/wrangler/src/__tests__/tail.test.ts b/packages/wrangler/src/__tests__/tail.test.ts index e07c8c5d588a..56edb3644bfb 100644 --- a/packages/wrangler/src/__tests__/tail.test.ts +++ b/packages/wrangler/src/__tests__/tail.test.ts @@ -4,7 +4,7 @@ import { vi } from "vitest"; import MockWebSocketServer from "vitest-websocket-mock"; import { mockAccountId, mockApiToken } from "./helpers/mock-account-id"; import { mockConsoleMethods } from "./helpers/mock-console"; -import { clearDialogs, mockConfirm } from "./helpers/mock-dialogs"; +import { clearDialogs } from "./helpers/mock-dialogs"; import { useMockIsTTY } from "./helpers/mock-istty"; import { MockWebSocket } from "./helpers/mock-web-socket"; import { createFetchResult, msw, mswSucessScriptHandlers } from "./helpers/msw"; @@ -69,7 +69,6 @@ describe("tail", () => { * deletion, and connection. */ describe("API interaction", () => { - const { setIsTTY } = useMockIsTTY(); it("should throw an error if name isn't provided", async () => { await expect( runWrangler("tail") @@ -77,23 +76,7 @@ describe("tail", () => { `[Error: Required Worker name missing. Please specify the Worker name in wrangler.toml, or pass it as an argument with \`wrangler tail \`]` ); }); - it("warns about durable object restarts for tty", async () => { - setIsTTY(true); - mockConfirm({ - text: "Would you like to continue?", - result: false, - }); - api = mockWebsocketAPIs(); - expect(api.requests.creation.length).toStrictEqual(0); - await runWrangler("tail durable-object--websocket--response"); - expect(std.out).toMatchInlineSnapshot(`""`); - expect(std.warn).toMatchInlineSnapshot(` - "▲ [WARNING] Beginning log collection requires restarting the Durable Objects associated with durable-object--websocket--response. Any WebSocket connections or other non-persisted state will be lost as part of this restart. - " - `); - expect(std.err).toMatchInlineSnapshot(`""`); - }); it("creates and then delete tails", async () => { api = mockWebsocketAPIs(); expect(api.requests.creation.length).toStrictEqual(0); diff --git a/packages/wrangler/src/tail/index.ts b/packages/wrangler/src/tail/index.ts index 733a5ab29d62..bbbb05cca939 100644 --- a/packages/wrangler/src/tail/index.ts +++ b/packages/wrangler/src/tail/index.ts @@ -1,8 +1,6 @@ import { setTimeout } from "node:timers/promises"; import onExit from "signal-exit"; -import { fetchResult, fetchScriptContent } from "../cfetch"; import { readConfig } from "../config"; -import { confirm } from "../dialogs"; import { createFatalError, UserError } from "../errors"; import { getLegacyScriptName, @@ -19,7 +17,6 @@ import { prettyPrintLogs, translateCLICommandToFilterMessage, } from "./createTail"; -import type { WorkerMetadata } from "../deployment-bundle/create-worker-upload-form"; import type { CommonYargsArgv, StrictYargsOptionsToInterface, @@ -129,29 +126,7 @@ export async function tailHandler(args: TailArgs) { clientIp: args.ip, versionId: args.versionId, }; - const scriptContent: string = await fetchScriptContent( - (!isLegacyEnv(config) ? args.env : undefined) - ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${args.env}/content` - : `/accounts/${accountId}/workers/scripts/${scriptName}` - ); - - const bindings = await fetchResult( - (!isLegacyEnv(config) ? args.env : undefined) - ? `/accounts/${accountId}/workers/services/${scriptName}/environments/${args.env}/bindings` - : `/accounts/${accountId}/workers/scripts/${scriptName}/bindings` - ); - if ( - scriptContent.toLowerCase().includes("websocket") && - bindings.find((b) => b.type === "durable_object_namespace") - ) { - logger.warn( - `Beginning log collection requires restarting the Durable Objects associated with ${scriptName}. Any WebSocket connections or other non-persisted state will be lost as part of this restart.` - ); - if (!(await confirm("Would you like to continue?"))) { - return; - } - } const filters = translateCLICommandToFilterMessage(cliFilters); const { tail, expiration, deleteTail } = await createTail(