Skip to content

Initialize Hosted installations within the deployment process - #264

Merged
tnkuehne merged 2 commits into
mainfrom
build/hosted-single-session
Nov 21, 2026
Merged

tnkuehne merged 2 commits into
mainfrom
build/hosted-single-session

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

A Hosted deployment (tools/deploy-hosted.ts) opened two remote Wrangler sessions through getPlatformProxy:

  1. one after the Runtime deploy, to check the active Runtime version through the private service binding
  2. one inside tools/initialize-cloudflare.ts, which ran as a separate Node process, to publish sign-in settings

The separate process also migrated the database a second time and loaded the control-plane modules again.

Changes:

  • tools/cloudflare-initialization.ts holds the initialization steps that previously lived in the script. The caller provides a migrated database and the platform bindings.
  • tools/deploy-hosted.ts opens the remote session once, uses it for the Runtime check and the initialization, and disposes of it at the end. Initialization runs in-process with the same configuration the child process received. Its errors are printed through the existing redaction before the tool exits.
  • tools/initialize-cloudflare.ts (pnpm initialize:cloudflare) keeps its behavior: it migrates, initializes, and opens a session only when it publishes settings.
  • connectCloudflareSettings takes the platform bindings instead of opening its own session.

Validation: type checks, lint and format pass. RUN_CLOUDFLARE_TESTS=1 vitest run tests/cloudflare/initialization.test.ts tests/cloudflare/hosted-installation.test.ts passes 24 of 24 tests, including initialization against workerd bindings. The deployment tool itself needs a Cloudflare account and was not run.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous cleanup finding is fixed.

Summary

Hosted deployments now initialize the installation in-process and share one Wrangler session with the Runtime check.

  • Hosted deployments initialize installations inside the deployment process.

Reviews (2) · Last reviewed commit: "Clean up after a failed platform session..." · Reviewed by Greptile

A Hosted deployment opened two remote Wrangler sessions: one to verify
the active Runtime version, and one in a separate initialization
process that published sign-in settings. The initialization process also
migrated the database again.

The initialization steps now live in a shared function. The deployment
calls it in-process with the session it opened for the Runtime check,
after its own migration. The initialize:cloudflare command keeps its
behavior: it migrates, initializes and opens its own session only when
it publishes settings.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs f4b441f Nov 21 2026, 01:39 PM

@tnkuehne
tnkuehne merged commit 53796b4 into main Nov 21, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the build/hosted-single-session branch November 21, 2026 23:59
tnkuehne added a commit that referenced this pull request Nov 22, 2026
)

#264 changed `connectCloudflareSettings` to take existing platform
bindings, so the deployment can share one session. Operator commands
that run on their own have no session to pass and relied on the helper
opening one from a Wrangler configuration.

- `connectCloudflareSettings` opens a session from `configPath` again
and returns `close`, as before #264.
- `createCloudflareSettings` takes existing bindings; Hosted
initialization uses it with the shared deployment session.

<!-- greptile_comment -->

<!-- greptile_summary -->

<h2><a
href="https://app.greptile.com/api/retrigger?id=115439918&amp;sig=84dce517bed30b1fa52ecdd30ce53a2f37b6749679def608de5d5419decb8b24"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img
alt="Retrigger"
src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"
align="right"></picture></a><a
href="https://app.greptile.com/-/switch-tenant?tenant=mendra&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F278&amp;utm_source=greptile_review&amp;utm_medium=github&amp;utm_campaign=view_in_greptile"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source
media="(prefers-color-scheme: light)"
srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img
alt="View in Greptile"
src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"
align="right"></picture></a>Confidence Score: 5/5</h2>

<!-- greptile-impact-verdict --> This PR appears safe to merge;
standalone and shared sessions have separate, clear owners.

<details open><summary><h3>Summary</h3></summary>

Restores `connectCloudflareSettings` as an async helper that opens a
Wrangler session and returns `close`.
- Standalone operator commands open a Cloudflare session from their
Wrangler config.
</details>

<details open><summary><h3>Diagram</h3></summary>

```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Standalone caller] --> B[connectCloudflareSettings]
  B --> C[Open Wrangler session]
  C --> D[createCloudflareSettings]
  D --> E[Return services and close]
  E --> F[Caller closes session]
  G[Hosted deployment] --> H[Open shared Wrangler session]
  H --> I[Check runtime and initialize installation]
  I --> D
  I --> J[Deployment finally closes shared session]
```
</details>

<!-- greptile_confidence_score:5 -->

<sub>Reviews (1) · Last reviewed commit: ["Let standalone operator
commands open
th..."](e62c14b)
· [Reviewed by
Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub>

<!-- /greptile_comment -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant