Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file based registry fixtures #6893

Merged
merged 37 commits into from
Oct 14, 2024
Merged

file based registry fixtures #6893

merged 37 commits into from
Oct 14, 2024

Conversation

RamIdeas
Copy link
Contributor

@RamIdeas RamIdeas commented Oct 4, 2024

What this PR solves / how to test

Fixes N/A

This PR removes flaky dev registry fixtures, and shifts them to be run in Wrangler's e2e test suite to improve reliability and reduce the number of times they're run.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because:
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because: shouldn't trigger a release
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal workflows change

Copy link

changeset-bot bot commented Oct 4, 2024

⚠️ No Changeset found

Latest commit: 66b0916

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 4, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-wrangler-6893

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6893/npm-package-wrangler-6893

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-wrangler-6893 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-create-cloudflare-6893 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-cloudflare-kv-asset-handler-6893
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-miniflare-6893
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-cloudflare-pages-shared-6893
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-cloudflare-vitest-pool-workers-6893
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-cloudflare-workers-editor-shared-6893
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11327304683/npm-package-cloudflare-workers-shared-6893

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.80.4 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241004.0
workerd 1.20241004.0 1.20241004.0
workerd --version 1.20241004.0 2024-10-04

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@penalosa penalosa added the e2e Run e2e tests on a PR label Oct 4, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are to support running with --x-registry

@@ -150,92 +115,6 @@ describe("getPlatformProxy - env", () => {
}
});

it("provides service bindings to external local workers", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now tested in the get-platform-proxy.test.ts e2e test

@@ -221,107 +216,6 @@ describe.each([
});
});

describe.each([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to dev-registry.test.ts

Comment on lines -48 to +49
if (stderr.length) {
console.error(stderr);
}
if (stdout.length) {
console.log(`[${path.basename(cwd ?? "/unknown")}]`, stdout);
}
if (stderr.length) {
console.error(`[${path.basename(cwd ?? "/unknown")}]`, stderr);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means our E2E test output will be a lot noisier, but I think we should keep logging enabled by default for now to help us diagnose and fix flakes

if (process.env.VITEST_MODE === "WATCH") {
console.log(line);
}
console.log(`[${path.basename(cwd ?? "/unknown")}]`, line);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Comment on lines +257 to +272
if (!buildAborter.signal.aborted) {
this.emitBundleCompleteEvent(config, newBundle);
this.#currentBundle = newBundle;
}
},
(err) =>
this.emitErrorEvent({
type: "error",
reason: "Failed to construct initial bundle",
cause: castErrorCause(err),
source: "BundlerController",
data: undefined,
})
(err) => {
if (!buildAborter.signal.aborted) {
this.emitErrorEvent({
type: "error",
reason: "Failed to construct initial bundle",
cause: castErrorCause(err),
source: "BundlerController",
data: undefined,
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BundleController had a race condition where old builds would sometimes overwrite newer ones. We'd thought this was handled by esbuild, but it turns out that it's not in the way we need it to. This fixes the intermittent "Failed to construct initial bundle" flakes we were seeing in E2E tests in CI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thanks for that.

Comment on lines +259 to +269
const registryDefinition = registry?.[script_name];
if (
registryDefinition &&
registryDefinition.durableObjects.some(
(d) => d.className === class_name
)
) {
value += ` (defined in 🟢 ${script_name})`;
} else {
value += ` (defined in 🔴 ${script_name})`;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it much easier to see at a glance which service bindings are connected via the dev registry. Happy to bikeshed on the emoji!

@penalosa penalosa marked this pull request as ready for review October 10, 2024 13:45
@penalosa penalosa requested a review from a team as a code owner October 10, 2024 13:45
Copy link
Contributor

@andyjessop andyjessop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One question, but otherwise really happy this is going forward 🚀

"dev",
publicPath,
"--x-dev-env",
"--x-registry",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎆

Comment on lines +257 to +272
if (!buildAborter.signal.aborted) {
this.emitBundleCompleteEvent(config, newBundle);
this.#currentBundle = newBundle;
}
},
(err) =>
this.emitErrorEvent({
type: "error",
reason: "Failed to construct initial bundle",
cause: castErrorCause(err),
source: "BundlerController",
data: undefined,
})
(err) => {
if (!buildAborter.signal.aborted) {
this.emitErrorEvent({
type: "error",
reason: "Failed to construct initial bundle",
cause: castErrorCause(err),
source: "BundlerController",
data: undefined,
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, thanks for that.

@@ -476,6 +476,11 @@ async function updateDevEnvRegistry(
devEnv: DevEnv,
registry: WorkerRegistry | undefined
) {
// Make sure we're not patching an empty config
if (!devEnv.config.latestConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change fixing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just moving this check higher up the function. Previously we got bound workers and then waited for a config update, but since getting bound workers depends on the config we should've been waiting here instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Does this explain the race we were seeing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of them, yes! Another was in the bundle controller, and there might still be others lurking

packages/wrangler/e2e/dev-registry.test.ts Outdated Show resolved Hide resolved
@@ -476,6 +476,11 @@ async function updateDevEnvRegistry(
devEnv: DevEnv,
registry: WorkerRegistry | undefined
) {
// Make sure we're not patching an empty config
if (!devEnv.config.latestConfig) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Does this explain the race we were seeing?

packages/wrangler/src/config/index.ts Outdated Show resolved Hide resolved
penalosa and others added 3 commits October 14, 2024 12:31
Co-authored-by: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com>
Co-authored-by: Rahul Sethi <5822355+RamIdeas@users.noreply.github.com>
@penalosa penalosa merged commit 07fe80b into main Oct 14, 2024
22 checks passed
@penalosa penalosa deleted the fix-x-registry branch October 14, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e tests on a PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants