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

fix: emulate event.platform during development even if route is undefined #12513

Merged
merged 8 commits into from
Sep 5, 2024

Conversation

yutak23
Copy link
Contributor

@yutak23 yutak23 commented Jul 28, 2024

This ought to fix #11996

Only if DEV, config is an empty object and prerender is set to false so that event.platform can be emulated.
I believe this will improve the development experience by preventing 500 errors and allowing development to occur in a more local development environment similar to the production environment.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Copy link

changeset-bot bot commented Jul 28, 2024

🦋 Changeset detected

Latest commit: 1ec990b

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@yutak23 yutak23 changed the title fix: in dev, emulate event.platform even if route is undefined fix: in dev, emulate event.platform even if route is undefined Jul 28, 2024
@yutak23 yutak23 changed the title fix: in dev, emulate event.platform even if route is undefined fix: emulate event.platform during development even if route is undefined Jul 28, 2024
@yutak23 yutak23 requested a review from eltigerchino July 28, 2024 11:52
Comment on lines 300 to 302
if (!event.platform && DEV && state.emulator?.platform) {
event.platform = await state.emulator.platform({ config: {}, prerender: false });
}
Copy link
Member

Choose a reason for hiding this comment

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

@benmccann is this what you meant in #11996 (comment) ? I suppose one more check we need to add is if we're currently rendering a fallback

@codenoid
Copy link
Contributor

codenoid commented Sep 4, 2024

Hi!, should this get merged?

I manually change Kit's node_modules file, and this change really made it to work

yutak23 and others added 2 commits September 5, 2024 11:21
Co-authored-by: Tee Ming <[email protected]>
Co-authored-by: Tee Ming <[email protected]>
@yutak23 yutak23 requested a review from eltigerchino September 5, 2024 02:23
@eltigerchino eltigerchino merged commit 109722c into sveltejs:main Sep 5, 2024
10 of 12 checks passed
@eltigerchino
Copy link
Member

Thank you! Sorry this took so long to merge.

@github-actions github-actions bot mentioned this pull request Sep 5, 2024
@yutak23 yutak23 deleted the feature/fix-platform-emulation branch September 5, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

adapter-cloudflare emulated bindings not always available
3 participants