Skip to content

workaround: LINE webhook route 404 on cold start (#49803)#3

Open
daniel-rudaev wants to merge 1 commit intomainfrom
fix/line-plugin-route-404
Open

workaround: LINE webhook route 404 on cold start (#49803)#3
daniel-rudaev wants to merge 1 commit intomainfrom
fix/line-plugin-route-404

Conversation

@daniel-rudaev
Copy link
Copy Markdown

Summary

Fixes LINE (and Google Chat, Mattermost) webhook routes returning 404 even when the plugin is enabled and configured.

Based on upstream PR openclaw/openclaw#53642 (open as of 2026-04-05).

Root Cause

When the bundler splits src/plugins/runtime.ts across multiple output chunks (registry-*.js for the gateway HTTP handler and pi-embedded-*.js for channel plugin runtimes), whichever chunk initializes globalThis[Symbol.for('openclaw.pluginRegistryState')] first determines its shape.

The gateway chunk initializes state with only { registry, key, version }, omitting httpRouteRegistry and httpRouteRegistryPinned. When the LINE plugin calls registerPluginHttpRoute()requireActivePluginHttpRouteRegistry(), the missing field causes routes to register on a fallback instance the gateway never queries.

Result: POST /line/webhook → 404.

Fix

patches/apply-line-plugin-route-fix.sh is applied during Docker build (before pnpm build). It defensively ensures httpRouteRegistry and httpRouteRegistryPinned fields exist on the shared state object in the IIFE initializer, regardless of which chunk creates it first.

+13 lines, 1 file (src/plugins/runtime.ts).

Bug: when OpenClaw starts, the LINE plugin registers its webhook route
(/line/webhook) but the bundler splits runtime.ts into two chunks. The
chunk that initialises the global registry object first creates it
without the httpRoute fields the other chunk expects — so the LINE
plugin registers into one registry and the HTTP server queries a
different one. Result: 404 on cold start, works after hot-reload.

Upstream fix PRs #53642 and #54686 are open but both stale against
the current refactored source (httpRoute structure changed completely).

Workaround: a background process in entrypoint.sh waits 20s after
gateway start, then writes a temporary `_reloadTs` field to
openclaw.json. The gateway's file-watcher detects the change and
hot-reloads the LINE channel, re-registering routes into the correct
registry. The field is removed 5s later.

This is explicitly documented as a workaround. Remove this block once
a real fix ships from upstream and is included in the source we build
from. See the extensive comment block in entrypoint.sh for full details,
upstream issue links, and the two PRs tracking the real fix.

Upstream issue: openclaw/openclaw#49803
Upstream PRs: openclaw/openclaw#53642, openclaw/openclaw#54686
@daniel-rudaev daniel-rudaev force-pushed the fix/line-plugin-route-404 branch from 3632bf5 to 251b773 Compare April 5, 2026 08:36
@daniel-rudaev daniel-rudaev changed the title fix: LINE/Google Chat webhook routes return 404 (#49803, PR #53642) workaround: LINE webhook route 404 on cold start (#49803) Apr 5, 2026
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