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

feat(worker-playground): delay preview environment setup #6962

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

edmundhung
Copy link
Member

@edmundhung edmundhung commented Oct 14, 2024

What this PR solves / how to test

Fixes DEVX-1410.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: Worker playground has no tests at the moment
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: No impact on other projects
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Changeset included
    • Changeset not necessary because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: No feature change

@edmundhung edmundhung requested a review from a team as a code owner October 14, 2024 10:17
Copy link

changeset-bot bot commented Oct 14, 2024

🦋 Changeset detected

Latest commit: 30f8387

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/quick-edit Minor
workers-playground Minor

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Oct 14, 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/11327229098/npm-package-wrangler-6962

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

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

Or you can use npx with this latest build directly:

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

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.

preview();

if (url === previewUrl) {
setRefreshTimestamp(new Date().toISOString());
Copy link
Member Author

Choose a reason for hiding this comment

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

The timestamp has no use but trigger the effect above (sendRequest) to re-run.

Comment on lines +67 to +72
const [url, setUrl] = useState(previewUrl);
const [refreshTimestamp, setRefreshTimestamp] = useState<string>();

const hasBody = method !== "HEAD" && method !== "GET" && method !== "OPTIONS";
useEffect(() => {
setUrl(previewUrl);
}, [previewUrl]);
Copy link
Member Author

Choose a reason for hiding this comment

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

We need an additional url state to load if the url is changed on submit. This is useful to decide whether we need to re-fetch the response from the same url.

},
[previewHash, setPreviewUrl, previewUrl, method, headers, hasBody, body]
);
const ensureDevtoolsConnected = useRef(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has this been deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

The variable ensureDevtoolsConnected was used to send the initial request. This is no longer needed as we have the useEffect to keep track of all the config and send a new request when needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this file need changed? It seems from a quick skim that it's doing roughly the same thing

Copy link
Member Author

Choose a reason for hiding this comment

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

We didn't share the URLBar implementation between the two tabs unlike the dashboard. Do you want me to fix that?

@penalosa penalosa added the preview:workers-playground Trigger a workers playground preview deploy label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview:workers-playground Trigger a workers playground preview deploy
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

2 participants