Repository navigation
release: v2.3.1 - #48
Conversation
- Fix TypeError: Method Promise.prototype.then called on incompatible receiver - Add special handling for Promise methods (then, catch, finally) in proxy get trap - Preserve Promise prototype chain by binding methods to original target - Maintain AsyncLocalStorage context propagation through Promise chains - Ensure new Promises from .then() chains are properly wrapped - Tested with both EAGER and LAZY loading modes - Verified Promise storage, awaiting, and chaining scenarios - Maintains full backward compatibility Resolves issue where async function returns were being proxied incorrectly, causing runtime errors when trying to await stored Promises or use .then() method.
This release resolves the Promise proxy issue in Slothlet's makeWrapper system. Empty commit to trigger automated release pipeline.
There was a problem hiding this comment.
Pull Request Overview
Release v2.3.1 to fix Promise proxy behavior by preserving the correct Promise prototype semantics during property access.
- Add special handling for Promise instance methods (then/catch/finally) in the proxy get trap to bind calls to the original promise.
- Bump package version to 2.3.1.
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib/runtime/runtime.mjs | Adjust proxy get trap to preserve Promise prototype chain and wrap returned Promises. |
| package.json | Update version to 2.3.1. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…s-realm compatibility - Replace instanceof Promise with util.types.isPromise() for cross-realm compatibility - Wrap Promise callback functions to preserve AsyncLocalStorage context - Ensure .then(), .catch(), and .finally() callbacks execute with proper runtime context - Fix callback context loss in Promise chains and stored Promises - Maintain full backward compatibility and proper prototype chain preservation - Tested with both EAGER and LAZY loading modes Addresses feedback on Promise proxy implementation to ensure robust context propagation through Promise chains and cross-realm safety.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…rovements - Replace instanceof Promise with util.types.isPromise() for cross-realm compatibility - Add support for thenable objects (non-native Promises with callable 'then') - Extract Promise method names to PROMISE_METHODS constant to avoid string repetition - Improve maintainability and reduce potential for typos in method name comparisons - Maintain full backward compatibility while expanding Promise-like object support - Preserve AsyncLocalStorage context across both native Promises and thenables Addresses feedback on Promise proxy implementation for robustness and code quality.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Fix TypeError: Method Promise.prototype.then called on incompatible receiver - Add support for both native Promises and thenables - Implement cross-realm compatibility with util.types.isPromise() - Use Reflect.apply for cross-realm safety - Extract Promise method names to PROMISE_METHODS constant - Add memoization cache for Promise method wrappers - Preserve AsyncLocalStorage context through Promise chains - Maintain proper prototype chain for Promise methods Resolves Promise chaining issues while preserving context isolation.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Fix Promise handler 'this' context to be undefined per Promise/A+ spec - Add cache invalidation when Promise methods are overwritten - Prevent stale wrapper functions for mutated thenables - Maintain proper Promise behavior while preserving context isolation Addresses GitHub Copilot suggestions for Promise proxy robustness.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Fix thenable detection to support catch/finally methods on custom thenables - Add cache invalidation for deleteProperty to prevent stale wrappers - Ensure all Promise methods (then/catch/finally) work on thenable objects - Improve proxy trap consistency for Promise method caching Addresses additional GitHub Copilot suggestions for edge case handling.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 2 out of 4 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
* release: v2.3.1 - Comprehensive Promise Proxy Fix and Cross-Realm Compatibility 🔧 PROMISE PROXY FIXES • Fix "TypeError: Method Promise.prototype.then called on incompatible receiver" when awaiting Promises from Slothlet API calls • Complete Promise method support (`.then()`, `.catch()`, `.finally()`) with proper prototype chain preservation • Cross-realm Promise compatibility using `util.types.isPromise()` for reliable Promise detection across different contexts • Enhanced thenable support for custom Promise-like objects with callable `then` methods • Promise/A+ specification compliance with proper `undefined` context for Promise handlers 📊 CONTEXT PRESERVATION ENHANCEMENTS • AsyncLocalStorage context isolation maintained through Promise chains and callbacks • Automatic context wrapping for Promise callback functions using `runWithCtx()` • Live-binding system integration with Promise execution contexts • Seamless integration with existing Slothlet runtime context management (`self`, `context`, `reference`) • Context preservation through complex Promise chains and nested callbacks 🛠 ADVANCED CACHING & PERFORMANCE • Per-target Promise method wrapper memoization using WeakMap-based cache system (`promiseMethodCache`) • Function identity preservation for repeated property access (maintains `promise.then === promise.then`) • Cache invalidation on property mutations (`set` and `deleteProperty` operations) to prevent stale wrappers • Cross-realm safety with `Reflect.apply` usage instead of direct function calls • Optimized thenable detection using `hasThen` pattern for broader compatibility 🧹 ROBUSTNESS & EDGE CASE HANDLING • Enhanced thenable detection supports all Promise methods (`catch`/`finally`) on custom thenable objects • Proper handling of Promise method deletion and overwriting with automatic cache cleanup • Prevention of stale wrapper functions when thenable objects mutate their methods after first access • Support for both native Promises and custom thenable implementations • Comprehensive proxy trap consistency across all property operations 🔒 CODE QUALITY IMPROVEMENTS • Extracted Promise method names to `PROMISE_METHODS` constant for maintainability • Improved error handling and cross-realm compatibility patterns • Enhanced debugging capabilities with structured error reporting • Better separation of concerns between Promise handling and general method wrapping • Consistent naming conventions with `runtime_` prefixes for debugging clarity Breaking Changes: None - all Promise functionality enhanced while maintaining backward compatibility Performance Impact: Minimal overhead with intelligent caching; significant improvement for Promise-heavy workloads This release resolves critical Promise proxy issues that caused TypeErrors when using async/await with Slothlet API methods, while adding comprehensive cross-realm compatibility and maintaining perfect AsyncLocalStorage context isolation throughout Promise execution chains. --------- Co-authored-by: Nate - CLDMV <Shinrai@users.noreply.github.com>
🚀 What's Changed
💥 Breaking Changes
No breaking changes
✨ Features
No new features
🐛 Bug Fixes
🔧 Other Changes
No other changes
👥 Contributors