Skip to content

Commit

Permalink
removes unnecessary wrangler tail warning against resetting durable o…
Browse files Browse the repository at this point in the history
…bject (#6160)

* removes unnecessary wrangler tail warning against resetting durable object

* removes commented out code
  • Loading branch information
sm-bean committed Jun 27, 2024
1 parent 61fbf8a commit 9466531
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 43 deletions.
7 changes: 7 additions & 0 deletions .changeset/tender-boxes-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"wrangler": patch
---

fix: removes unnecessary wrangler tail warning against resetting durable object

fixes https://jira.cfdata.org/browse/STOR-3318
19 changes: 1 addition & 18 deletions packages/wrangler/src/__tests__/tail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -69,31 +69,14 @@ 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")
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: Required Worker name missing. Please specify the Worker name in wrangler.toml, or pass it as an argument with \`wrangler tail <worker-name>\`]`
);
});
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);
Expand Down
25 changes: 0 additions & 25 deletions packages/wrangler/src/tail/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,7 +17,6 @@ import {
prettyPrintLogs,
translateCLICommandToFilterMessage,
} from "./createTail";
import type { WorkerMetadata } from "../deployment-bundle/create-worker-upload-form";
import type {
CommonYargsArgv,
StrictYargsOptionsToInterface,
Expand Down Expand Up @@ -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<WorkerMetadata["bindings"]>(
(!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(
Expand Down

0 comments on commit 9466531

Please sign in to comment.