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 streaming in Node.js fast path #11058

Merged
merged 7 commits into from
May 16, 2024
Merged

Fix streaming in Node.js fast path #11058

merged 7 commits into from
May 16, 2024

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented May 15, 2024

Changes

  • Rendering occurs before the response starts asking for data.
  • This resulted in a scenario where the first render would resolve a promise that the iterator was not listening to.
  • This resulting in waiting until the next render to actually start streaming.
  • The fix is to prevent rendering from creating the promises and instead only resolve them. Now the iterator is in charge of the promise and creates them on each pull.

Testing

  • Updated existing test which only checked for more than 1 chunks when there should be several.
  • Added a new assertion to verify that the first chunk does not contain the promise-blocked content.

Docs

N/A, bug fix

Copy link

changeset-bot bot commented May 15, 2024

🦋 Changeset detected

Latest commit: 848a3dc

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

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label May 15, 2024
@matthewp
Copy link
Contributor Author

!preview node-streaming

Copy link
Contributor

Snapshots have been released for the following packages:

  • astro@experimental--node-streaming
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--node-streaming tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/db
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/web-vitals
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-node-streaming-20240515211034) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.6 is already published on npm
🦋  warn create-astro is not being published because version 4.8.0 is already published on npm
🦋  warn @astrojs/db is not being published because version 0.11.2 is already published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/lit is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.11.0 is already published on npm
🦋  warn @astrojs/mdx is not being published because version 3.0.0 is already published on npm
🦋  warn @astrojs/node is not being published because version 8.2.5 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.1.0 is already published on npm
🦋  warn @astrojs/preact is not being published because version 3.3.0 is already published on npm
🦋  warn @astrojs/react is not being published because version 3.3.4 is already published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.1.4 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 4.2.0 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.4.0 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/vercel is not being published because version 7.6.0 is already published on npm
🦋  warn @astrojs/vue is not being published because version 4.2.0 is already published on npm
🦋  warn @astrojs/web-vitals is not being published because version 0.1.1 is already published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.3.0 is already published on npm
🦋  info Publishing "astro" at "0.0.0-node-streaming-20240515211034"
🦋  success packages published successfully:
🦋  astro@0.0.0-node-streaming-20240515211034
🦋  Creating git tag...
🦋  New tag:  astro@0.0.0-node-streaming-20240515211034
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/db, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @astrojs/web-vitals, @benchmark/timer, astro, create-astro
• Running build in 28 packages
• Remote caching enabled
::group::create-astro:build
cache hit, suppressing logs 785aab1edd72bb57
::endgroup::
::group::@astrojs/telemetry:build
cache hit, suppressing logs 95bd2f8cbca89f97
::endgroup::
::group::@astrojs/upgrade:build
cache hit, suppressing logs 72c72bf9c48ba3e0
::endgroup::
::group::@astrojs/internal-helpers:build
cache hit, suppressing logs eb5867eac3983ee3
::endgroup::
::group::@astrojs/prism:build
cache hit, suppressing logs 601194e64df38a11
::endgroup::
::group::@astrojs/markdown-remark:build
cache hit, suppressing logs 09627d1426328c42
::endgroup::
::group::astro:build
cache miss, executing 08c5424424d4918d

> astro@0.0.0-node-streaming-20240515211034 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-node-streaming-20240515211034 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-node-streaming-20240515211034 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@benchmark/timer:build
cache miss, executing f110008fd7604e25

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/lit:build
cache miss, executing 8673129027b6122b

> @astrojs/lit@4.0.1 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing 1988b77383cf4038

> @astrojs/partytown@2.1.0 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing 43641a25c7f9a1b9

> @astrojs/rss@4.0.6 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing b462317576151406

> @astrojs/tailwind@5.1.0 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/node:build
cache miss, executing de702b61380a80a8

> @astrojs/node@8.2.5 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing 605706078450daad

> @astrojs/markdoc@0.11.0 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing ed82f08341d1160e

> @astrojs/mdx@3.0.0 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 16fd9957235adef5

> @astrojs/vue@4.2.0 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing 55e4cabc0f2181d3

> @astrojs/preact@3.3.0 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/react:build
cache miss, executing dbe70e203dc14c1b

> @astrojs/react@3.3.4 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing cac4e2176e196135

> @astrojs/solid-js@4.2.0 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing 27e3615e3d19c8fc

> @astrojs/alpinejs@0.4.0 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing be88ca572e665fcb

> @astrojs/vercel@7.6.0 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing d88c37ac7789b509

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 44572df893e14828

> @astrojs/svelte@5.4.0 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 2824bc08643c6fa4

> @astrojs/sitemap@3.1.4 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/db:build
cache miss, executing 23c236c3df8047d7

> @astrojs/db@0.11.2 build /home/runner/work/astro/astro/packages/db
> astro-scripts build "src/**/*.ts" && tsc && pnpm types:virtual


> @astrojs/db@0.11.2 types:virtual /home/runner/work/astro/astro/packages/db
> tsc -p ./tsconfig.virtual.json

::endgroup::
::group::@astrojs/web-vitals:build
cache miss, executing 1609796f4d0eb387

> @astrojs/web-vitals@0.1.1 build /home/runner/work/astro/astro/packages/integrations/web-vitals
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    26 successful, 26 total
Cached:    6 cached, 26 total
  Time:    47.939s 

@matthewp matthewp marked this pull request as ready for review May 16, 2024 13:59
Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

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

Looks right to me! Unsure if the renderingComplete is needed, since I'd assume next() won't be triggered again if rendering has completed. But I don't know the wider context.

@matthewp
Copy link
Contributor Author

@bholmesdev i'll add a comment explaining why it's needed.

@matthewp matthewp merged commit 749a7ac into main May 16, 2024
13 checks passed
@matthewp matthewp deleted the fix-streaming branch May 16, 2024 16:36
@astrobot-houston astrobot-houston mentioned this pull request May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants