Skip to content

Chunked Encoding / Server Sent Events Pre-Work #24

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

Merged
merged 1 commit into from
Jul 11, 2025
Merged

Conversation

thecodedrift
Copy link
Member

This resolves #23 by doing the following:

  • Adds new support for a chunk method that may exist in WebAssembly Packs
  • Checks the new methods property in the pre2 manifest that is optional. It allows the Pack author to declare which lifecycle methods are available
  • Refactors the lifecycle calls to make them easier to manage since pre / post behaves differently than chunk
  • Renames handler.ts to msw.ts for clarity
  • Moves the id, error, and logger files to a more general util folder
  • Refactors console logging to work with the larger farm-out operation that prioritizes returning a response to the client over waiting for the webassembly lifecycle

@thecodedrift thecodedrift requested a review from Copilot July 11, 2025 05:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for a “chunk” lifecycle in the WebAssembly pack flow, centralizes lifecycle handling, updates logging to allow optional data logging, and reorganizes utility files for clarity.

  • Introduce a new chunk executor and wiring through the runPackLifecycle dispatcher
  • Refactor runSandbox into a unified run function handling pre, chunk, and post phases
  • Add an enableDataLogging flag to createLogger and relocate errors, IDs, and logger into util

Reviewed Changes

Copilot reviewed 15 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/util/logger.ts Added enableDataLogging flag and simplified log-level function setup
src/lib/taskless.ts Updated imports, hooked enableDataLogging into logger, integrated chunk
src/lib/sandbox.ts Refactored sandbox runner into run using shared lifecycle executors
src/lib/msw.ts Renamed handler logic to msw.ts, updated calls to run and ID imports
src/lib/lifecycle/types.ts Defined LifecycleCallbacks and executor signature
src/lib/lifecycle/pre.ts Implemented pre lifecycle respecting optional methods
src/lib/lifecycle/post.ts Implemented post lifecycle respecting optional methods
src/lib/lifecycle/chunk.ts Added chunk lifecycle for streaming response bodies
src/lib/lifecycle/helpers.ts Extended sandbox payload creator to include chunk and binary support
src/lib/lifecycle.ts Central dispatcher for pre, post, and chunk executors
src/index.ts Adjusted environment merging logic to filter undefined sources
scripts/generate.ts Removed WASM directory cleanup
.prettierignore Added vendor directory to ignore list
.eslintignore Added src/vendor directory to ignore list
.changeset/twenty-toes-laugh.md Documented new chunked event-stream support
Files not reviewed (4)
  • src/generated/manifest.ts: Language not supported
  • src/generated/openapi.ts: Language not supported
  • src/generated/pack.ts: Language not supported
  • src/generated/schema.ts: Language not supported
Comments suppressed due to low confidence (3)

src/lib/taskless.ts:130

  • The variable useLogging is not defined in this scope, leading to a reference error. Replace it with the correct option (e.g., options.enableDataLogging) or declare it properly.
  const logger = createLogger(options?.logLevel, options?.log, useLogging);

src/lib/sandbox.ts:8

  • The isDefined helper now drops all falsy but valid values (0, '', false). Consider using value !== undefined to only filter out undefined.
  return Boolean(value && value !== undefined);

src/index.ts:104

  • This check skips falsy but valid environment values (0, '', false). It should explicitly test for value === undefined instead to only skip missing entries.
      if (!value) {

@thecodedrift thecodedrift merged commit be93c12 into main Jul 11, 2025
1 check passed
@thecodedrift thecodedrift deleted the chunk_support branch July 11, 2025 21:40
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.

SSE Support
1 participant