Skip to content

Commit 6cac351

Browse files
Revert "Don't require Hyperdrive local connection string when using wrangler …" (#7545)
This reverts commit a98dfa0.
1 parent f13c897 commit 6cac351

File tree

3 files changed

+1
-54
lines changed

3 files changed

+1
-54
lines changed

.changeset/nervous-jeans-obey.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/wrangler/e2e/dev.test.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -555,49 +555,6 @@ describe("hyperdrive dev tests", () => {
555555
await socketMsgPromise;
556556
});
557557

558-
it("does not require local connection string when running `wrangler dev --remote`", async () => {
559-
const helper = new WranglerE2ETestHelper();
560-
await helper.seed({
561-
"wrangler.toml": dedent`
562-
name = "${workerName}"
563-
main = "src/index.ts"
564-
compatibility_date = "2023-10-25"
565-
566-
[[hyperdrive]]
567-
binding = "HYPERDRIVE"
568-
id = "hyperdrive_id"
569-
`,
570-
"src/index.ts": dedent`
571-
export default {
572-
async fetch(request, env) {
573-
if (request.url.includes("connect")) {
574-
const conn = env.HYPERDRIVE.connect();
575-
await conn.writable.getWriter().write(new TextEncoder().encode("test string"));
576-
}
577-
return new Response(env.HYPERDRIVE?.connectionString ?? "no")
578-
}
579-
}`,
580-
"package.json": dedent`
581-
{
582-
"name": "worker",
583-
"version": "0.0.0",
584-
"private": true
585-
}
586-
`,
587-
});
588-
589-
const worker = helper.runLongLived("wrangler dev --remote");
590-
591-
const { url } = await worker.waitForReady();
592-
const text = await fetchText(url);
593-
594-
const hyperdrive = new URL(text);
595-
expect(hyperdrive.pathname).toBe("/some_db");
596-
expect(hyperdrive.username).toBe("user");
597-
expect(hyperdrive.password).toBe("!pass");
598-
expect(hyperdrive.host).not.toBe("localhost");
599-
});
600-
601558
afterEach(() => {
602559
if (server.listening) {
603560
server.close();

packages/wrangler/src/dev.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,12 +1042,7 @@ export function getBindings(
10421042
process.env[
10431043
`WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive.binding}`
10441044
];
1045-
// only require a local connection string in the wrangler file or the env if not using dev --remote
1046-
if (
1047-
local &&
1048-
!connectionStringFromEnv &&
1049-
!hyperdrive.localConnectionString
1050-
) {
1045+
if (!connectionStringFromEnv && !hyperdrive.localConnectionString) {
10511046
throw new UserError(
10521047
`When developing locally, you should use a local Postgres connection string to emulate Hyperdrive functionality. Please setup Postgres locally and set the value of the 'WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive.binding}' variable or "${hyperdrive.binding}"'s "localConnectionString" to the Postgres connection string.`
10531048
);

0 commit comments

Comments
 (0)