Skip to content

Commit

Permalink
Revert "Don't require Hyperdrive local connection string when using w…
Browse files Browse the repository at this point in the history
…rangler …" (#7545)

This reverts commit a98dfa0.
  • Loading branch information
CarmenPopoviciu authored Dec 13, 2024
1 parent f13c897 commit 6cac351
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 54 deletions.
5 changes: 0 additions & 5 deletions .changeset/nervous-jeans-obey.md

This file was deleted.

43 changes: 0 additions & 43 deletions packages/wrangler/e2e/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,49 +555,6 @@ describe("hyperdrive dev tests", () => {
await socketMsgPromise;
});

it("does not require local connection string when running `wrangler dev --remote`", async () => {
const helper = new WranglerE2ETestHelper();
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-10-25"
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "hyperdrive_id"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env) {
if (request.url.includes("connect")) {
const conn = env.HYPERDRIVE.connect();
await conn.writable.getWriter().write(new TextEncoder().encode("test string"));
}
return new Response(env.HYPERDRIVE?.connectionString ?? "no")
}
}`,
"package.json": dedent`
{
"name": "worker",
"version": "0.0.0",
"private": true
}
`,
});

const worker = helper.runLongLived("wrangler dev --remote");

const { url } = await worker.waitForReady();
const text = await fetchText(url);

const hyperdrive = new URL(text);
expect(hyperdrive.pathname).toBe("/some_db");
expect(hyperdrive.username).toBe("user");
expect(hyperdrive.password).toBe("!pass");
expect(hyperdrive.host).not.toBe("localhost");
});

afterEach(() => {
if (server.listening) {
server.close();
Expand Down
7 changes: 1 addition & 6 deletions packages/wrangler/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,12 +1042,7 @@ export function getBindings(
process.env[
`WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_${hyperdrive.binding}`
];
// only require a local connection string in the wrangler file or the env if not using dev --remote
if (
local &&
!connectionStringFromEnv &&
!hyperdrive.localConnectionString
) {
if (!connectionStringFromEnv && !hyperdrive.localConnectionString) {
throw new UserError(
`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.`
);
Expand Down

0 comments on commit 6cac351

Please sign in to comment.