Skip to content

Commit

Permalink
Revert "Hyperdrive dev remote fix" (#7868)
Browse files Browse the repository at this point in the history
* Revert "Hyperdrive dev remote fix (#7783)"

This reverts commit a2f695b.

* Create silver-pillows-listen.md
  • Loading branch information
penalosa authored Jan 22, 2025
1 parent bdc7958 commit 78a9a2d
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 104 deletions.
5 changes: 0 additions & 5 deletions .changeset/nervous-jeans-obey.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/silver-pillows-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Revert "Hyperdrive dev remote fix". This PR includes e2e tests that were not run before merging, and are currently failing.
1 change: 0 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
HYPERDRIVE_DATABASE_URL: ${{ secrets.TEST_HYPERDRIVE_DATABASE_URL}}
WRANGLER: node --no-warnings ${{ github.workspace}}/packages/wrangler/bin/wrangler.js
WRANGLER_IMPORT: ${{ github.workspace}}/packages/wrangler/wrangler-dist/cli.js
NODE_OPTIONS: "--max_old_space_size=8192"
Expand Down
30 changes: 1 addition & 29 deletions packages/wrangler/e2e/dev-with-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,35 +580,6 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
);
});

it("exposes Hyperdrive bindings", async () => {
const { id } = await helper.hyperdrive(false);

await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-10-25"
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "${id}"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env) {
if (request.url.includes("connect")) {
const conn = env.HYPERDRIVE.connect();
}
return new Response(env.HYPERDRIVE?.connectionString ?? "no")
}
}`,
});

const worker = helper.runLongLived(`wrangler dev ${flags}`);
const { url } = await worker.waitForReady();
await fetch(`${url}/connect`);
});

it.skipIf(!isLocal).fails("exposes Pipelines bindings", async () => {
await helper.seed({
"wrangler.toml": dedent`
Expand Down Expand Up @@ -721,6 +692,7 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
});

// TODO(soon): implement E2E tests for other bindings
it.todo("exposes hyperdrive bindings");
it.skipIf(isLocal).todo("exposes send email bindings");
it.skipIf(isLocal).todo("exposes browser bindings");
it.skipIf(isLocal).todo("exposes Workers AI bindings");
Expand Down
38 changes: 0 additions & 38 deletions packages/wrangler/e2e/dev.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,44 +653,6 @@ describe("hyperdrive dev tests", () => {
await socketMsgPromise;
});

it("does not require local connection string when running `wrangler dev --remote`", async () => {
const helper = new WranglerE2ETestHelper();
const { id } = await helper.hyperdrive(false);

await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2023-10-25"
[[hyperdrive]]
binding = "HYPERDRIVE"
id = "${id}"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env) {
if (request.url.includes("connect")) {
const conn = env.HYPERDRIVE.connect();
}
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();
await fetch(`${url}/connect`);
});

afterEach(() => {
if (server.listening) {
server.close();
Expand Down
23 changes: 0 additions & 23 deletions packages/wrangler/e2e/helpers/e2e-wrangler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,4 @@ export class WranglerE2ETestHelper {

return name;
}

async hyperdrive(isLocal: boolean): Promise<{ id: string; name: string }> {
const name = generateResourceName("hyperdrive");

if (isLocal) {
return { id: crypto.randomUUID(), name };
}

const result = await this.run(
`wrangler hyperdrive create ${name} --connection-string="${process.env.HYPERDRIVE_DATABASE_URL}"`
);
const tomlMatch = /id = "([0-9a-f]{32})"/.exec(result.stdout);
const jsonMatch = /"id": "([0-9a-f]{32})"/.exec(result.stdout);
const match = jsonMatch ?? tomlMatch;
assert(match !== null, `Cannot find ID in ${JSON.stringify(result)}`);
const id = match[1];

onTestFinished(async () => {
await this.run(`wrangler hyperdrive delete ${name}`);
});

return { id, name };
}
}
7 changes: 1 addition & 6 deletions packages/wrangler/src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,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
3 changes: 1 addition & 2 deletions packages/wrangler/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"WRANGLER_DISABLE_EXPERIMENTAL_WARNING",
"WRANGLER_DISABLE_REQUEST_BODY_DRAINING",
"WRANGLER_WORKER_REGISTRY_PORT",
"WRANGLER_API_ENVIRONMENT",
"HYPERDRIVE_DATABASE_URL"
"WRANGLER_API_ENVIRONMENT"
]
},
"test:ci": {
Expand Down

0 comments on commit 78a9a2d

Please sign in to comment.