René's URL Explorer Experiment


Title: fix(mothership): answer a retried task wake whose turn already ran by waleedlatif1 · Pull Request #8484 · simstudioai/sim · GitHub

Open Graph Title: fix(mothership): answer a retried task wake whose turn already ran by waleedlatif1 · Pull Request #8484 · simstudioai/sim

X Title: fix(mothership): answer a retried task wake whose turn already ran by waleedlatif1 · Pull Request #8484 · simstudioai/sim

Description: Summary Problem. The worker retries a task wake under the same run ID until it sees its own run for that ID. When sim accepted the wake but the headless turn ended inside sim without reaching the worker (for example, a usage-limit refusal), the worker never saw a run. It retried the wake, sim accepted it again, and the loop never ended. Root cause. prepareTaskWake only checked the chat stream lock. It had no idea that a turn under this run ID had already run, so every retry looked like a new wake. Fix. After prepareTaskWake takes the chat lock, it looks up the latest run for the wake's run ID. If a turn already ran under that ID, it answers not_found (404), and the worker drops the notification instead of retrying. The check runs while the lock is held, so a turn that is still running under that ID keeps answering busy (409). If the lookup throws, or the wake answers not-found, the lock taken moments earlier is released. The wake turn that would normally release it never starts, and without this the chat would stay locked. ensureHeadlessRunIdentity now logs the underlying error and keeps it as the cause of its generic "execution record is unavailable" error, so the failure can be diagnosed. Behaviour changes A retried wake whose turn already ended now gets 404 (it used to get 202 and run again). A retried wake whose turn is still holding the chat still gets 409. If the run lookup fails, the wake gets 500 and the chat lock is released. A failed headless run-record insert is now logged with its cause. The error message returned to callers has not changed. Test plan prepare-wake.integration.ts runs against real PostgreSQL and Redis through the wake route. It covers the not-found retry, a busy retry while the turn still holds the chat, and releasing the lock when the lookup fails. Red then green: with prepare-wake.ts reverted to staging, the not-found and lock-release tests fail. The busy test passes both before and after the fix; it is there to keep the new check from turning an in-flight turn's 409 into a 404. Related unit tests pass: lib/mothership/tasks, lib/mothership/request/lifecycle, app/api/mothership/wake. bun run type-check (apps/sim), biome on the changed files, and bun run check:test-patterns all pass. Staging check: a wake whose turn was refused for usage limits stops being retried.

Open Graph Description: Summary Problem. The worker retries a task wake under the same run ID until it sees its own run for that ID. When sim accepted the wake but the headless turn ended inside sim without reaching the w...

X Description: Summary Problem. The worker retries a task wake under the same run ID until it sees its own run for that ID. When sim accepted the wake but the headless turn ended inside sim without reaching the w...

Opengraph URL: https://github.com/simstudioai/sim/pull/8484

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d2f19c34-320e-c01b-110a-5cda0c53a8af
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE0A0:B85F4:1CF5931:273AC73:6AFB950A
html-safe-nonce75f5c2fa157a0742dcf5adfaa207ae4e71a457e66543d78744d650825b596bda
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEEwOkI4NUY0OjFDRjU5MzE6MjczQUM3Mzo2QUZCOTUwQSIsInZpc2l0b3JfaWQiOiI3OTg4Mjc4OTY2MzMyNjU4OTU0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac129d30584b6770fafd63c949fe8470b54fd1fc6578c1290731df697debb69546
hovercard-subject-tagpull_request:4696689495
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8484/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Problem. The worker retries a task wake under the same run ID until it sees its own run for that ID. When sim accepted the wake but the headless turn ended inside sim without reaching the w...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea52db8866b6543b4e83730cd6a6b1360f1a9e4dc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/8484/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F8484%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F8484%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/8484/files
Reloadhttps://github.com/simstudioai/sim/pull/8484/files
Reloadhttps://github.com/simstudioai/sim/pull/8484/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests198 (198)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/task-wake-idempotent-deliveryhttps://github.com/simstudioai/sim/tree/fix/task-wake-idempotent-delivery
Conversation 26 https://github.com/simstudioai/sim/pull/8484
Commits 4 https://github.com/simstudioai/sim/pull/8484/commits
Checks 31 https://github.com/simstudioai/sim/pull/8484/checks
Files changed https://github.com/simstudioai/sim/pull/8484/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
fix(mothership): answer a retried task wake whose turn already ran https://github.com/simstudioai/sim/pull/8484/files#top
Show all changes 4 commits https://github.com/simstudioai/sim/pull/8484/files
85986a7 fix(mothership): answer a retried task wake whose turn already ran waleedlatif1 Sep 30, 2026 https://github.com/simstudioai/sim/pull/8484/commits/85986a768829e709d18b853fadc455c1e8ffc5f0
0bd25e7 fix(mothership): release the wake's chat lock when the run lookup fails waleedlatif1 Sep 30, 2026 https://github.com/simstudioai/sim/pull/8484/commits/0bd25e71a13f9029c1d0d3e6897d42f36d21165d
7cb813b fix(mothership): release the wake's own chat lease when the run looku… waleedlatif1 Sep 30, 2026 https://github.com/simstudioai/sim/pull/8484/commits/7cb813b1fc12a2d4739928e6fd33fcb36b5e4ad2
4ed2f71 test(mothership): stub the chat lease getter in the wake unit test mock waleedlatif1 Sep 30, 2026 https://github.com/simstudioai/sim/pull/8484/commits/4ed2f71727bfecf8ab2841318278ed26ae89cb4d
Clear filters https://github.com/simstudioai/sim/pull/8484/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
run.ts https://github.com/simstudioai/sim/pull/8484/files#diff-42286b1c13539c62ff83806b87ad5eb1669e4ce1e893862f952cf81cdc440573
prepare-wake.integration.ts https://github.com/simstudioai/sim/pull/8484/files#diff-911688c6c0d2031d88ba61a3cea13b19d7d5c9375e6f722959cc75092f9a049d
prepare-wake.ts https://github.com/simstudioai/sim/pull/8484/files#diff-a79a3e3297d387ebe27e826010ee0dc4a4cec4806cce1ff03bb87585872e9d98
tasks.test.ts https://github.com/simstudioai/sim/pull/8484/files#diff-b015fe02eac7aeb751fd3a0506ad284e82cdec501a5552807a002bebae788360
apps/sim/lib/mothership/request/lifecycle/run.tshttps://github.com/simstudioai/sim/pull/8484/files#diff-42286b1c13539c62ff83806b87ad5eb1669e4ce1e893862f952cf81cdc440573
View file https://github.com/simstudioai/sim/blob/4ed2f71727bfecf8ab2841318278ed26ae89cb4d/apps/sim/lib/mothership/request/lifecycle/run.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8484/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8484/files#diff-42286b1c13539c62ff83806b87ad5eb1669e4ce1e893862f952cf81cdc440573
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
https://github.com/simstudioai/sim/pull/8484/files#diff-42286b1c13539c62ff83806b87ad5eb1669e4ce1e893862f952cf81cdc440573
apps/sim/lib/mothership/tasks/application/prepare-wake.integration.tshttps://github.com/simstudioai/sim/pull/8484/files#diff-911688c6c0d2031d88ba61a3cea13b19d7d5c9375e6f722959cc75092f9a049d
View file https://github.com/simstudioai/sim/blob/4ed2f71727bfecf8ab2841318278ed26ae89cb4d/apps/sim/lib/mothership/tasks/application/prepare-wake.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8484/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
apps/sim/lib/mothership/tasks/application/prepare-wake.tshttps://github.com/simstudioai/sim/pull/8484/files#diff-a79a3e3297d387ebe27e826010ee0dc4a4cec4806cce1ff03bb87585872e9d98
View file https://github.com/simstudioai/sim/blob/4ed2f71727bfecf8ab2841318278ed26ae89cb4d/apps/sim/lib/mothership/tasks/application/prepare-wake.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8484/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8484/files#diff-a79a3e3297d387ebe27e826010ee0dc4a4cec4806cce1ff03bb87585872e9d98
https://github.com/simstudioai/sim/pull/8484/files#diff-a79a3e3297d387ebe27e826010ee0dc4a4cec4806cce1ff03bb87585872e9d98
https://github.com/simstudioai/sim/pull/8484/files#diff-a79a3e3297d387ebe27e826010ee0dc4a4cec4806cce1ff03bb87585872e9d98
apps/sim/lib/mothership/tasks/application/tasks.test.tshttps://github.com/simstudioai/sim/pull/8484/files#diff-b015fe02eac7aeb751fd3a0506ad284e82cdec501a5552807a002bebae788360
View file https://github.com/simstudioai/sim/blob/4ed2f71727bfecf8ab2841318278ed26ae89cb4d/apps/sim/lib/mothership/tasks/application/tasks.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/8484/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/8484/files#diff-b015fe02eac7aeb751fd3a0506ad284e82cdec501a5552807a002bebae788360
https://github.com/simstudioai/sim/pull/8484/files#diff-b015fe02eac7aeb751fd3a0506ad284e82cdec501a5552807a002bebae788360
Please reload this pagehttps://github.com/simstudioai/sim/pull/8484/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.