Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cloudflare/workers-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: miniflare@3.20240129.1
Choose a base ref
...
head repository: cloudflare/workers-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: miniflare@3.20240129.2
Choose a head ref

Commits on Feb 7, 2024

  1. [C3] Add getBindingsProxy support to qwik template (#4927)

    * Split package.json update into multiple phases
    
    * Add getBindingsProxy to qwik template
    
    * Add support for testing dev scripts in c3 e2e tests
    
    * Refactor framework e2e verification helpers
    
    * Add support for verifying build script in framework e2es
    
    * Refactor e2e helpers
    
    * Refactor workers e2e tests to re-align with frameworks tests
    
    * Refactor RunnerConfig in e2e tests
    
    * Fixing cli e2e tests
    
    * changeset
    
    * remove leftover test value
    
    * Fix issue with npm tests & fix e2e logging
    
    * Addressing PR feedback
    jculvey authored Feb 7, 2024
    Copy the full SHA
    49696ab View commit details
  2. Copy the full SHA
    e5cdd7f View commit details
  3. Copy the full SHA
    ff45782 View commit details
  4. Copy the full SHA
    75bd08a View commit details
  5. fix: make the entrypoint optional for the types command (#4931)

    ---------
    
    Co-authored-by: MrBBot <bcoll@cloudflare.com>
    dario-piotrowicz and mrbbot authored Feb 7, 2024
    Copy the full SHA
    321c7ed View commit details
  6. add a cf field to the getBindingsProxy result (#4926)

    ---------
    
    Co-authored-by: James Culveyhouse <jculveyhouse@cloudflare.com>
    dario-piotrowicz and jculvey authored Feb 7, 2024
    Copy the full SHA
    a14bd1d View commit details
  7. Improve DX with node:* modules (#4499)

    * Turn node build failures into warnings
    
    * Allow files to suppress warnings for specific modules
    
    * Remove comment-based allow-listing
    
    * Add changeset
    
    * Update .changeset/chatty-balloons-impress.md
    
    Co-authored-by: James M Snell <jasnell@gmail.com>
    
    * Pass through `defineNavigatorUserAgent`
    
    * Add tests
    
    * lockfile
    
    * Linting
    
    * fix tests
    
    ---------
    
    Co-authored-by: James M Snell <jasnell@gmail.com>
    penalosa and jasnell authored Feb 7, 2024
    Copy the full SHA
    cf9c029 View commit details
  8. improve(r2): Update Sippy endpoint request payloads to match new sche…

    …ma (#4928)
    
    * fix(r2): update Sippy API request payloads
    
    * improve(r2): rename sippy flags for clarity
    
    * improve(r2): stricter existence in Sippy
    sdnts authored Feb 7, 2024
    Copy the full SHA
    4a735c4 View commit details

Commits on Feb 8, 2024

  1. [C3] Bump create-qwik from 1.4.3 to 1.4.4 in /packages/create-cloudfl…

    …are/src/frameworks (#4935)
    
    * [C3] Bump create-qwik in /packages/create-cloudflare/src/frameworks
    
    Bumps [create-qwik](https://github.com/BuilderIO/qwik/tree/HEAD/packages/create-qwik) from 1.4.3 to 1.4.4.
    - [Release notes](https://github.com/BuilderIO/qwik/releases)
    - [Commits](https://github.com/BuilderIO/qwik/commits/v1.4.4/packages/create-qwik)
    
    ---
    updated-dependencies:
    - dependency-name: create-qwik
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 8, 2024
    Copy the full SHA
    0699506 View commit details
  2. Copy the full SHA
    d96bc7d View commit details
  3. Extend error handling of proxy request errors in ProxyWorker (#4867)

    * ignore stale proxy errors
    
    * attempt to recover from ProxyWorker fetch errors
    by requeuing the request (only if it is GET or HEAD)
    
    * add test
    
    * add changeset
    
    * refactor to flatten nested if-else blocks
    
    * requeue request for retry at front of queue
    
    * sort batch of requests in queue by order of arrival
    
    * Revert "sort batch of requests in queue by order of arrival"
    
    This reverts commit 3329f19.
    
    * Revert "requeue request for retry at front of queue"
    
    This reverts commit f0377b7.
    
    * prioritise requests being retried
    over requests being proxied for the first time
    
    * better comments
    
    * update changeset to match recommeded format
    RamIdeas authored Feb 8, 2024
    Copy the full SHA
    d637bd5 View commit details
  4. Copy the full SHA
    4eb4d7f View commit details
  5. Version Packages (#4934)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    workers-devprod and github-actions[bot] authored Feb 8, 2024
    Copy the full SHA
    a71afaf View commit details

Commits on Feb 9, 2024

  1. [D1] fix batch splitting to handle CASE as compound statement starts (#…

    …4951)
    
    * fix: add CASE to compound statement starts
    
    * chore: add changeset
    
    * chore: cleanup and add tests
    
    * chore: improve test coverage
    
    * chore: delete leftover file
    
    * chore: add missed commit
    
    * Update packages/wrangler/src/d1/splitter.ts
    
    Co-authored-by: Max Rozen <3822106+rozenmd@users.noreply.github.com>
    
    ---------
    
    Co-authored-by: Max Rozen <3822106+rozenmd@users.noreply.github.com>
    nora-soderlund and rozenmd authored Feb 9, 2024
    Copy the full SHA
    ffafe8a View commit details
  2. [C3] Bump @angular/create from 17.1.2 to 17.1.3 in /packages/create-c…

    …loudflare/src/frameworks (#4963)
    
    * [C3] Bump @angular/create in /packages/create-cloudflare/src/frameworks
    
    Bumps [@angular/create](https://github.com/angular/angular-cli) from 17.1.2 to 17.1.3.
    - [Release notes](https://github.com/angular/angular-cli/releases)
    - [Changelog](https://github.com/angular/angular-cli/blob/main/CHANGELOG.md)
    - [Commits](angular/angular-cli@17.1.2...17.1.3)
    
    ---
    updated-dependencies:
    - dependency-name: "@angular/create"
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * [C3] Update frameworks cli dependencies
    
    ---------
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Wrangler automated PR updater <wrangler@cloudflare.com>
    dependabot[bot] and Wrangler automated PR updater authored Feb 9, 2024
    Copy the full SHA
    b3110c3 View commit details
  3. fix: ensure worker reloads when importing node:* modules (#4962)

    * fix: ensure worker reloads when importing `node:*` modules
    
    * fix: ensure conflicting compatibility flags reported as user error
    
    * fix: add type arguments to `seen` and `warnedPackaged`
    mrbbot authored Feb 9, 2024
    Copy the full SHA
    d658517 View commit details
  4. Copy the full SHA
    96c8cfb View commit details
  5. fix: ensure we do not rewrite external Origin headers in wrangler dev (

    …#4950)
    
    fix: ensure we do not rewrite external Origin headers in wrangler dev
    
    In #4812 we tried to fix the Origin headers to match the Host header but were overzealous and rewrote Origin headers for external origins (outside of the proxy server's origin).
    
    This is now fixed, and moreover we rewrite any headers that refer to the proxy server on the request with the configured host and vice versa on the response.
    
    This should ensure that CORS is not broken in browsers when a different host is being simulated based on routes in the Wrangler configuration.
    petebacondarwin authored Feb 9, 2024
    Copy the full SHA
    05360e4 View commit details
  6. Initial commit

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    1cd18e0 View commit details
  7. Remove webpack

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    224a254 View commit details
  8. remove webpack config

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    e2c77cd View commit details
  9. Add README

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    1c75c30 View commit details
  10. Copy the full SHA
    e6eaa60 View commit details
  11. Copy the full SHA
    a7f76e3 View commit details
  12. Remove simple wordage

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    22f8ae3 View commit details
  13. Copy the full SHA
    78b04b3 View commit details
  14. Copy the full SHA
    37011c8 View commit details
  15. Copy the full SHA
    2092b65 View commit details
  16. Copy the full SHA
    d3975da View commit details
  17. Copy the full SHA
    74cfd96 View commit details
  18. Merge pull request #1 from cloudflare/avery/remove-condition

    Remove condition and class - export a single function
    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    3100713 View commit details
  19. Copy the full SHA
    4e32404 View commit details
  20. formatting

    exvuma authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    2748963 View commit details
  21. Copy the full SHA
    94d3250 View commit details
  22. Merge pull request #3 from cloudflare/victoria/prettier

    formatting
    exvuma authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    c8bbe96 View commit details
  23. Copy the full SHA
    9f31c32 View commit details
  24. Averys suggestions

    exvuma authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    72aeebb View commit details
  25. Merge pull request #2 from cloudflare/victoria/path

    set up default and optional path handler
    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    df30acb View commit details
  26. Fix readme typo

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    5de4be1 View commit details
  27. Copy the full SHA
    2d42645 View commit details
  28. Copy the full SHA
    7d5932c View commit details
  29. Update comment

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    a843c5f View commit details
  30. Copy the full SHA
    634a791 View commit details
  31. Fix typos

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    285c744 View commit details
  32. Formatting

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    f1af037 View commit details
  33. Tests passing

    EverlastingBugstopper authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    12d17e5 View commit details
  34. 0.0.1

    ashleygwilliams authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    831093b View commit details
  35. Copy the full SHA
    2150293 View commit details
  36. Copy the full SHA
    ff138f2 View commit details
  37. Caching controls

    exvuma authored and GregBrimble committed Feb 9, 2024
    Copy the full SHA
    adbd636 View commit details
Showing with 6,437 additions and 1,302 deletions.
  1. +1 −0 .github/workflows/c3-e2e-project-cleanup.yml
  2. +12 −0 .github/workflows/{choose-pages-projects.yml → deploy-pages-projects.yml}
  3. +3 −0 CODEOWNERS
  4. +11 −11 fixtures/additional-modules/test/index.test.ts
  5. +1 −1 fixtures/dev-env/package.json
  6. +51 −2 fixtures/dev-env/tests/index.test.ts
  7. +1 −1 fixtures/get-bindings-proxy/package.json
  8. +15 −23 fixtures/get-bindings-proxy/tests/get-bindings-proxy.bindings.test.ts
  9. +43 −0 fixtures/get-bindings-proxy/tests/get-bindings-proxy.cf.test.ts
  10. +3 −0 fixtures/get-platform-proxy/.dev.vars
  11. +1 −0 fixtures/get-platform-proxy/custom-toml/path/.dev.vars
  12. +7 −0 fixtures/get-platform-proxy/custom-toml/path/test-toml
  13. +16 −0 fixtures/get-platform-proxy/package.json
  14. +34 −0 fixtures/get-platform-proxy/tests/get-platform-proxy.caches.test.ts
  15. +43 −0 fixtures/get-platform-proxy/tests/get-platform-proxy.cf.test.ts
  16. +55 −0 fixtures/get-platform-proxy/tests/get-platform-proxy.ctx.test.ts
  17. +257 −0 fixtures/get-platform-proxy/tests/get-platform-proxy.env.test.ts
  18. +13 −0 fixtures/get-platform-proxy/tests/shared.ts
  19. +16 −0 fixtures/get-platform-proxy/tsconfig.json
  20. +10 −0 fixtures/get-platform-proxy/vitest.config.ts
  21. +11 −0 fixtures/get-platform-proxy/workers/do-worker-a/index.ts
  22. +5 −0 fixtures/get-platform-proxy/workers/do-worker-a/wrangler.toml
  23. +11 −0 fixtures/get-platform-proxy/workers/do-worker-b/index.ts
  24. +5 −0 fixtures/get-platform-proxy/workers/do-worker-b/wrangler.toml
  25. +5 −0 fixtures/get-platform-proxy/workers/hello-worker-a/index.ts
  26. +1 −0 fixtures/get-platform-proxy/workers/hello-worker-a/wrangler.toml
  27. +5 −0 fixtures/get-platform-proxy/workers/hello-worker-b/index.ts
  28. +1 −0 fixtures/get-platform-proxy/workers/hello-worker-b/wrangler.toml
  29. +11 −0 fixtures/get-platform-proxy/wrangler.json
  30. +32 −0 fixtures/get-platform-proxy/wrangler.toml
  31. +1 −1 fixtures/interactive-dev-tests/vitest.config.ts
  32. +12 −12 fixtures/local-mode-tests/tests/module.test.ts
  33. +47 −0 fixtures/local-mode-tests/tests/specified-port.test.ts
  34. +13 −13 fixtures/local-mode-tests/tests/sw.test.ts
  35. +2 −1 fixtures/worker-app/src/index.js
  36. +29 −2 fixtures/worker-app/tests/index.test.ts
  37. +3 −3 package.json
  38. +1 −0 packages/create-cloudflare/.eslintrc.js
  39. +17 −0 packages/create-cloudflare/CHANGELOG.md
  40. +35 −26 packages/create-cloudflare/e2e-tests/cli.test.ts
  41. +10 −0 packages/create-cloudflare/e2e-tests/fixtures/qwik/src/routes/test/index.ts
  42. +2 −0 packages/create-cloudflare/e2e-tests/fixtures/qwik/wrangler.toml
  43. +400 −210 packages/create-cloudflare/e2e-tests/frameworks.test.ts
  44. +122 −73 packages/create-cloudflare/e2e-tests/helpers.ts
  45. +125 −114 packages/create-cloudflare/e2e-tests/workers.test.ts
  46. +1 −1 packages/create-cloudflare/package.json
  47. +4 −4 packages/create-cloudflare/scripts/common.ts
  48. +4 −4 packages/create-cloudflare/scripts/e2eCleanup.ts
  49. +5 −2 packages/create-cloudflare/src/cli.ts
  50. +2 −2 packages/create-cloudflare/src/frameworks/package.json
  51. +21 −0 packages/create-cloudflare/src/helpers/codemod.ts
  52. +26 −12 packages/create-cloudflare/src/templates.ts
  53. +60 −4 packages/create-cloudflare/templates/qwik/c3.ts
  54. +1 −0 packages/create-cloudflare/tsconfig.json
  55. +17 −0 packages/edge-preview-authenticated-proxy/src/index.ts
  56. +40 −8 packages/edge-preview-authenticated-proxy/tests/index.test.ts
  57. +528 −0 packages/kv-asset-handler/CHANGELOG.md
  58. +346 −0 packages/kv-asset-handler/README.md
  59. +58 −0 packages/kv-asset-handler/package.json
  60. +355 −0 packages/kv-asset-handler/src/index.ts
  61. +152 −0 packages/kv-asset-handler/src/mocks.ts
  62. +32 −0 packages/kv-asset-handler/src/test/getAssetFromKV-optional.ts
  63. +552 −0 packages/kv-asset-handler/src/test/getAssetFromKV.ts
  64. +39 −0 packages/kv-asset-handler/src/test/mapRequestToAsset.ts
  65. +44 −0 packages/kv-asset-handler/src/test/serveSinglePageApp.ts
  66. +52 −0 packages/kv-asset-handler/src/types.ts
  67. +19 −0 packages/kv-asset-handler/tsconfig.json
  68. +12 −0 packages/miniflare/CHANGELOG.md
  69. +2 −2 packages/miniflare/package.json
  70. +0 −4 packages/miniflare/src/workers/core/entry.worker.ts
  71. +7 −0 packages/pages-shared/CHANGELOG.md
  72. +1 −1 packages/pages-shared/__tests__/asset-server/responses.test.ts
  73. +1 −1 packages/pages-shared/package.json
  74. +4 −0 packages/playground-preview-worker/.eslintrc.js
  75. +3 −1 packages/playground-preview-worker/package.json
  76. +124 −0 packages/playground-preview-worker/src/errors.ts
  77. +11 −116 packages/playground-preview-worker/src/index.ts
  78. +1 −1 packages/playground-preview-worker/src/realish.ts
  79. +2 −2 packages/playground-preview-worker/src/sentry.ts
  80. +68 −40 packages/playground-preview-worker/src/user.do.ts
  81. +115 −6 packages/playground-preview-worker/tests/index.test.ts
  82. +10 −5 packages/quick-edit/README.md
  83. +26 −0 packages/workers-playground/README.md
  84. +112 −112 packages/workers.new/tests/__snapshots__/index.test.ts.snap
  85. +12 −0 packages/wrangler-devtools/README.md
  86. +135 −0 packages/wrangler/CHANGELOG.md
  87. +8 −8 packages/wrangler/e2e/c3-integration.test.ts
  88. +11 −11 packages/wrangler/e2e/deployments.test.ts
  89. +7 −2 packages/wrangler/e2e/dev.test.ts
  90. +1 −1 packages/wrangler/e2e/pages-dev.test.ts
  91. +7 −7 packages/wrangler/e2e/r2.test.ts
  92. +11 −3 packages/wrangler/package.json
  93. +3 −0 packages/wrangler/scripts/deps.ts
  94. +48 −25 packages/wrangler/scripts/emit-types.ts
  95. +21 −0 packages/wrangler/src/__tests__/custom-build.test.ts
  96. +47 −1 packages/wrangler/src/__tests__/d1/splitter.test.ts
  97. +13 −10 packages/wrangler/src/__tests__/deploy.test.ts
  98. +193 −0 packages/wrangler/src/__tests__/navigator-user-agent.test.ts
  99. +12 −11 packages/wrangler/src/__tests__/pages/functions-build.test.ts
  100. +28 −17 packages/wrangler/src/__tests__/r2.test.ts
  101. +20 −0 packages/wrangler/src/__tests__/type-generation.test.ts
  102. +45 −0 packages/wrangler/src/api/integrations/deprecated/getBindingsProxy.ts
  103. +1 −0 packages/wrangler/src/api/integrations/deprecated/index.ts
  104. +2 −1 packages/wrangler/src/api/integrations/index.ts
  105. +1 −1 packages/wrangler/src/api/integrations/{bindings → platform}/caches.ts
  106. 0 packages/wrangler/src/api/integrations/{bindings → platform}/executionContext.ts
  107. +42 −15 packages/wrangler/src/api/integrations/{bindings → platform}/index.ts
  108. 0 packages/wrangler/src/api/integrations/{bindings → platform}/services.ts
  109. +8 −0 packages/wrangler/src/api/pages/deploy.tsx
  110. +1 −1 packages/wrangler/src/api/startDevWorker/events.ts
  111. +2 −0 packages/wrangler/src/d1/create.tsx
  112. +2 −0 packages/wrangler/src/d1/delete.ts
  113. +2 −0 packages/wrangler/src/d1/execute.tsx
  114. +2 −1 packages/wrangler/src/d1/info.tsx
  115. +2 −0 packages/wrangler/src/d1/list.tsx
  116. +2 −0 packages/wrangler/src/d1/migrations/apply.tsx
  117. +2 −0 packages/wrangler/src/d1/migrations/create.tsx
  118. +2 −0 packages/wrangler/src/d1/migrations/list.tsx
  119. +2 −2 packages/wrangler/src/d1/splitter.ts
  120. +18 −0 packages/wrangler/src/deploy/deploy.ts
  121. +6 −1 packages/wrangler/src/deployment-bundle/bundle.ts
  122. +67 −4 packages/wrangler/src/deployment-bundle/esbuild-plugins/nodejs-compat.ts
  123. +17 −9 packages/wrangler/src/deployment-bundle/run-custom-build.ts
  124. +5 −0 packages/wrangler/src/dev/dev.tsx
  125. +10 −4 packages/wrangler/src/dev/remote.tsx
  126. +10 −2 packages/wrangler/src/dev/start-server.ts
  127. +4 −0 packages/wrangler/src/dev/use-esbuild.ts
  128. +21 −0 packages/wrangler/src/navigator-user-agent.ts
  129. +14 −1 packages/wrangler/src/pages/build.ts
  130. +4 −0 packages/wrangler/src/pages/buildFunctions.ts
  131. +8 −0 packages/wrangler/src/pages/dev.ts
  132. +2 −0 packages/wrangler/src/pages/functions/buildPlugin.ts
  133. +9 −0 packages/wrangler/src/pages/functions/buildWorker.ts
  134. +36 −21 packages/wrangler/src/r2/helpers.ts
  135. +72 −38 packages/wrangler/src/r2/sippy.ts
  136. +8 −2 packages/wrangler/src/type-generation.ts
  137. +5 −0 packages/wrangler/src/versions/upload.ts
  138. +97 −34 packages/wrangler/templates/startDevWorker/ProxyWorker.ts
  139. +970 −247 pnpm-lock.yaml
  140. +3 −1 vitest.shared.ts
1 change: 1 addition & 0 deletions .github/workflows/c3-e2e-project-cleanup.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

name: C3 E2E Project Cleanup
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * *" # Run at 3am each day
env:
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
name: Deploy all Pages sites

# On a push to `main` or a PR that has one of the `preview:...`` labels,
# deploy the matching Pages project to Cloudflare.
#
# PR Label | Pages Project
# ---------------------------------------------------------
# preview:wrangler-devtools | packages/wrangler-devtools
# preview:quick-edit | packages/quick-edit
# preview:workers-playground | packages/workers-playground
#
# Note: these actions are not for running tests against these packages,
# only for deploying.

on:
push:
branches:
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@
# C3 ownership
/packages/create-cloudflare/ @cloudflare/c3

# kv-asset-handler ownership
/packages/kv-asset-handler/ @cloudflare/developer-advocacy @kristianfreeman @rickyrobinett @lauragift21 @LoganGrasby @craigsdennis

# Owners intentionally left blank on these shared directories
# to avoid noisy review requests
/.changeset/
22 changes: 11 additions & 11 deletions fixtures/additional-modules/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -167,33 +167,33 @@ describe("find_additional_modules deploy", () => {
const bundledEntry = await fs.readFile(bundledEntryPath, "utf8");
expect(bundledEntry).toMatchInlineSnapshot(`
"// src/index.ts
import common from \\"./common.cjs\\";
import common from "./common.cjs";
// src/dep.ts
var dep_default = \\"bundled\\";
var dep_default = "bundled";
// src/index.ts
import text from \\"./text.txt\\";
import text from "./text.txt";
var src_default = {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname === \\"/dep\\") {
if (url.pathname === "/dep") {
return new Response(dep_default);
}
if (url.pathname === \\"/text\\") {
if (url.pathname === "/text") {
return new Response(text);
}
if (url.pathname === \\"/common\\") {
if (url.pathname === "/common") {
return new Response(common);
}
if (url.pathname === \\"/dynamic\\") {
return new Response((await import(\\"./dynamic.js\\")).default);
if (url.pathname === "/dynamic") {
return new Response((await import("./dynamic.js")).default);
}
if (url.pathname.startsWith(\\"/lang/\\")) {
const language = \\"./lang/\\" + url.pathname.substring(\\"/lang/\\".length) + \\".js\\";
if (url.pathname.startsWith("/lang/")) {
const language = "./lang/" + url.pathname.substring("/lang/".length) + ".js";
return new Response((await import(language)).default.hello);
}
return new Response(\\"Not Found\\", { status: 404 });
return new Response("Not Found", { status: 404 });
}
};
export {
2 changes: 1 addition & 1 deletion fixtures/dev-env/package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"@types/ws": "^8.5.7",
"@cloudflare/workers-tsconfig": "workspace:^",
"get-port": "^7.0.0",
"miniflare": "3.20240129.1",
"miniflare": "3.20240129.2",
"undici": "^5.28.2",
"wrangler": "workspace:*",
"ws": "^8.14.2"
53 changes: 51 additions & 2 deletions fixtures/dev-env/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ describe("startDevWorker: ProxyController", () => {
fireAndForgetFakeUserWorkerChanges({
mfOpts: run.mfOpts,
config: run.config,
script: run.mfOpts.script.replace("1", "2"),
script: run.mfOpts.script.replace("body:1", "body:2"),
});

res = await run.worker.fetch("http://dummy");
@@ -295,7 +295,7 @@ describe("startDevWorker: ProxyController", () => {
fireAndForgetFakeUserWorkerChanges({
mfOpts: run.mfOpts,
config: run.config,
script: run.mfOpts.script.replace("1", "2"),
script: run.mfOpts.script.replace("body:1", "body:2"),
});
await executionContextClearedPromise;
});
@@ -599,4 +599,53 @@ describe("startDevWorker: ProxyController", () => {
"URL: https://mybank.co.uk/test/path/2"
);
});

test("inflight requests are retried during UserWorker reloads", async () => {
// to simulate inflight requests failing during UserWorker reloads,
// we will use a UserWorker with a longish `await setTimeout(...)`
// so that we can guarantee the race condition is hit
// when workerd is eventually terminated

const run = await fakeStartUserWorker({
script: `
export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname === '/long') {
await new Promise(r => setTimeout(r, 30_000));
}
return new Response("UserWorker:1");
}
}
`,
});

res = await run.worker.fetch("http://dummy/short"); // implicitly waits for UserWorker:1 to be ready
await expect(res.text()).resolves.toBe("UserWorker:1");

const inflightDuringReloads = run.worker.fetch("http://dummy/long");

// this will cause workerd for UserWorker:1 to terminate (eventually, but soon)
fireAndForgetFakeUserWorkerChanges({
mfOpts: run.mfOpts,
config: run.config,
script: run.mfOpts.script.replace("UserWorker:1", "UserWorker:2"), // change response so it can be identified
});

res = await run.worker.fetch("http://dummy/short"); // implicitly waits for UserWorker:2 to be ready
await expect(res.text()).resolves.toBe("UserWorker:2");

// this will cause workerd for UserWorker:2 to terminate (eventually, but soon)
fireAndForgetFakeUserWorkerChanges({
mfOpts: run.mfOpts,
config: run.config,
script: run.mfOpts.script
.replace("UserWorker:1", "UserWorker:3") // change response so it can be identified
.replace("30_000", "0"), // remove the long wait as we won't reload this UserWorker
});

res = await inflightDuringReloads;
await expect(res.text()).resolves.toBe("UserWorker:3");
});
});
2 changes: 1 addition & 1 deletion fixtures/get-bindings-proxy/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "get-bindings-proxy-fixture",
"private": true,
"description": "A test for the getBindingsProxy utility",
"description": "A test for the getBindingsProxy (deprecated) utility",
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
Original file line number Diff line number Diff line change
@@ -6,13 +6,11 @@ import {
Fetcher,
R2Bucket,
} from "@cloudflare/workers-types";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import {
getBindingsProxy as originalGetBindingsProxy,
unstable_dev,
} from "wrangler";
import { describe, expect, it } from "vitest";
import { unstable_dev } from "wrangler";
import { getBindingsProxy } from "./shared";
import type { KVNamespace } from "@cloudflare/workers-types";
import type { GetBindingsProxyOptions, UnstableDevWorker } from "wrangler";
import type { UnstableDevWorker } from "wrangler";

type Bindings = {
MY_VAR: string;
@@ -30,27 +28,21 @@ type Bindings = {

const wranglerTomlFilePath = path.join(__dirname, "..", "wrangler.toml");

// Here we wrap the actual original getBindingsProxy function and disable its persistance, this is to make sure
// that we don't implement any persistance during these tests (which would add unnecessary extra complexity)
function getBindingsProxy<T>(
options: Omit<GetBindingsProxyOptions, "persist">
): ReturnType<typeof originalGetBindingsProxy<T>> {
return originalGetBindingsProxy({
...options,
persist: false,
});
}

describe("getBindingsProxy - bindings", () => {
let devWorkers: UnstableDevWorker[];

beforeAll(async () => {
devWorkers = await startWorkers();
});
// Note: we're skipping the service workers and durable object tests
// so there's no need to start separate workers right now, the
// following beforeAll and afterAll should be un-commented when
// we reenable the tests

afterAll(async () => {
await Promise.allSettled(devWorkers.map((i) => i.stop()));
});
// beforeAll(async () => {
// devWorkers = await startWorkers();
// });

// afterAll(async () => {
// await Promise.allSettled(devWorkers.map((i) => i.stop()));
// });

describe("var bindings", () => {
it("correctly obtains var bindings from both wrangler.toml and .dev.vars", async () => {
43 changes: 43 additions & 0 deletions fixtures/get-bindings-proxy/tests/get-bindings-proxy.cf.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, expect, it } from "vitest";
import { getBindingsProxy } from "./shared";

describe("getBindingsProxy - cf", () => {
it("should provide mock data", async () => {
const { cf, dispose } = await getBindingsProxy();
try {
expect(cf).toMatchObject({
colo: "DFW",
city: "Austin",
regionCode: "TX",
});
} finally {
await dispose();
}
});

it("should match the production runtime cf object", async () => {
const { cf, dispose } = await getBindingsProxy();
try {
expect(cf.constructor.name).toBe("Object");

expect(() => {
cf.city = "test city";
}).toThrowError(
"Cannot assign to read only property 'city' of object '#<Object>'"
);
expect(cf.city).not.toBe("test city");

expect(() => {
cf.newField = "test new field";
}).toThrowError("Cannot add property newField, object is not extensible");
expect("newField" in cf).toBe(false);

expect(cf.botManagement).toMatchObject({
score: 99,
});
expect(Object.isFrozen(cf.botManagement)).toBe(true);
} finally {
await dispose();
}
});
});
3 changes: 3 additions & 0 deletions fixtures/get-platform-proxy/.dev.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MY_DEV_VAR = "my-dev-var-value"
MY_VAR_A = "my-dev-var-a"
MY_KV = "my-dev-kv"
1 change: 1 addition & 0 deletions fixtures/get-platform-proxy/custom-toml/path/.dev.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MY_DEV_VAR = "my-dev-var-value-from-a-custom-location"
7 changes: 7 additions & 0 deletions fixtures/get-platform-proxy/custom-toml/path/test-toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "get-bindings-proxy-fixture"
main = "src/index.ts"
compatibility_date = "2023-11-21"

[vars]
MY_VAR = "my-var-value-from-a-custom-toml"
MY_JSON_VAR = { test = true, customToml = true }
16 changes: 16 additions & 0 deletions fixtures/get-platform-proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "get-platform-proxy-fixture",
"private": true,
"description": "A test for the getPlatformProxy utility",
"scripts": {
"test": "vitest run",
"test:watch": "vitest",
"type:tests": "tsc --noEmit"
},
"devDependencies": {
"@cloudflare/workers-tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20221111.1",
"wrangler": "workspace:*",
"undici": "^5.28.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Request, Response } from "undici";
import { describe, expect, it } from "vitest";
import { getPlatformProxy } from "./shared";

describe("getPlatformProxy - caches", () => {
(["default", "named"] as const).forEach((cacheType) =>
it(`correctly obtains a no-op ${cacheType} cache`, async () => {
const { caches, dispose } = await getPlatformProxy();
try {
const cache =
cacheType === "default"
? caches.default
: await caches.open("my-cache");
testNoOpCache(cache);
} finally {
await dispose();
}
})
);
});

async function testNoOpCache(
cache: Awaited<ReturnType<typeof getPlatformProxy>>["caches"]["default"]
) {
let match = await cache.match("http://0.0.0.0/test");
expect(match).toBeUndefined();

const req = new Request("http://0.0.0.0/test");
await cache.put(req, new Response("test"));
const resp = await cache.match(req);
expect(resp).toBeUndefined();
const deleted = await cache.delete(req);
expect(deleted).toBe(false);
}
43 changes: 43 additions & 0 deletions fixtures/get-platform-proxy/tests/get-platform-proxy.cf.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { describe, expect, it } from "vitest";
import { getPlatformProxy } from "./shared";

describe("getPlatformProxy - cf", () => {
it("should provide mock data", async () => {
const { cf, dispose } = await getPlatformProxy();
try {
expect(cf).toMatchObject({
colo: "DFW",
city: "Austin",
regionCode: "TX",
});
} finally {
await dispose();
}
});

it("should match the production runtime cf object", async () => {
const { cf, dispose } = await getPlatformProxy();
try {
expect(cf.constructor.name).toBe("Object");

expect(() => {
cf.city = "test city";
}).toThrowError(
"Cannot assign to read only property 'city' of object '#<Object>'"
);
expect(cf.city).not.toBe("test city");

expect(() => {
cf.newField = "test new field";
}).toThrowError("Cannot add property newField, object is not extensible");
expect("newField" in cf).toBe(false);

expect(cf.botManagement).toMatchObject({
score: 99,
});
expect(Object.isFrozen(cf.botManagement)).toBe(true);
} finally {
await dispose();
}
});
});
Loading