feat: adds waitUntil support for edge environments#39
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Thank you for following the naming conventions! 🙏 |
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds support for Cloudflare Workers and Vercel Edge serverless environments by detecting and utilizing the waitUntil() API to ensure log drain operations complete before the runtime terminates.
Changes:
- Extended
ServerEventtype definition to include optionalcloudflare.context.waitUntilandwaitUntilproperties for Cloudflare Workers and Vercel Edge contexts - Modified
callDrainHookfunction in the Nitro plugin to detect and usewaitUntil()when available, preferring Cloudflare's implementation over Vercel's - Added comprehensive test suite with 5 test cases covering Cloudflare Workers, Vercel Edge, mixed contexts, traditional Node.js, and null event scenarios
- Updated adapter documentation with a callout highlighting automatic serverless support
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/evlog/src/types.ts | Extends ServerEvent interface with optional cloudflare and waitUntil properties to support serverless runtime contexts |
| packages/evlog/src/nitro/plugin.ts | Refactors callDrainHook to detect and use platform-specific waitUntil() API for ensuring drain completion in serverless environments |
| packages/evlog/test/nitro-plugin.test.ts | Adds comprehensive test suite covering all waitUntil scenarios including Cloudflare Workers, Vercel Edge, preference logic, and edge cases |
| apps/docs/content/3.adapters/1.overview.md | Adds informational callout documenting automatic serverless support for Cloudflare Workers and Vercel Edge |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds robust support for serverless environments (Cloudflare Workers and Vercel Edge) by ensuring that log drain operations are completed before the runtime terminates. This is achieved by detecting and utilizing the
waitUntil()API provided by these platforms. The changes also include comprehensive tests to verify this behavior and update the documentation to highlight the new feature.