Skip to content

Clear pending promise on rejection in memoized function#5

Open
dbeckham wants to merge 1 commit intodatocms:mainfrom
dbeckham:memoization-promise-rejection
Open

Clear pending promise on rejection in memoized function#5
dbeckham wants to merge 1 commit intodatocms:mainfrom
dbeckham:memoization-promise-rejection

Conversation

@dbeckham
Copy link
Copy Markdown

This fixes an issue where the memoized() function will cache failed promises permanently (until restart), causing all subsequent calls to return the same rejected promise. This prevented retries after timeout or rejection errors.

I discovered this bug while trying to track down odd lock timeout errors I was seeing (reported in #4). This bug was keeping me from being able to troubleshoot the problem because I'd have to restart the MCP server after each failure to clear the lock failure.

Changes:

  • Added rejection handler to clear 'pending' variable on promise failure. This allows retries after failures instead of permanent failure state
  • Added tests to cover successful caching, rejection handling, and retry behavior

Fixes the issue where workspace initialization timeouts would permanently block all script operations with 'lock timeout' errors until server restart.

The memoized() function was caching failed promises permanently, causing
all subsequent calls to return the same rejected promise. This prevented
retries after timeout or rejection errors.

Changes:
- Added rejection handler to clear 'pending' variable on promise failure
- Allows retries after failures instead of permanent failure state
- Added tests to cover successful caching, rejection handling, and retry behavior

Fixes the issue where workspace initialization timeouts would permanently
block all script operations with 'lock timeout' errors until server restart.
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.

1 participant