Skip to content

release: v2.3.1 - #48

Merged
Shinrai merged 9 commits into
masterfrom
release/2.3.1
Oct 17, 2025
Merged

Shinrai merged 9 commits into
masterfrom
release/2.3.1

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Oct 17, 2025 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

  • fix: enhance thenable detection and cache invalidation robustness (33b9fa5)

🔧 Other Changes

No other changes

👥 Contributors

Shinrai and others added 3 commits October 16, 2025 17:21
- 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.
@cldmv-bot cldmv-bot Bot added semver: explicit This release uses an explicitly specified version rather than an auto-detected bump release Marks a pull request as a pending release — merge to publish a new version labels Oct 17, 2025
@Shinrai Shinrai self-assigned this Oct 17, 2025
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 00:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/runtime/runtime.mjs
Comment thread src/lib/runtime/runtime.mjs Outdated
…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.
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 01:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/runtime/runtime.mjs
Comment thread src/lib/runtime/runtime.mjs Outdated
…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.
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 01:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/runtime/runtime.mjs Outdated
Comment thread src/lib/runtime/runtime.mjs Outdated
Comment thread src/lib/runtime/runtime.mjs Outdated
- 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.
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 02:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/runtime/runtime.mjs Outdated
Comment thread src/lib/runtime/runtime.mjs Outdated
- 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.
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 03:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/lib/runtime/runtime.mjs Outdated
Comment thread src/lib/runtime/runtime.mjs Outdated
- 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.
@Shinrai
Shinrai requested a review from Copilot October 17, 2025 03:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@Shinrai
Shinrai merged commit 1887c1c into master Oct 17, 2025
33 checks passed
@Shinrai
Shinrai deleted the release/2.3.1 branch October 22, 2025 16:44
Shinrai added a commit that referenced this pull request Feb 11, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Marks a pull request as a pending release — merge to publish a new version semver: explicit This release uses an explicitly specified version rather than an auto-detected bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants