wechaty/wechaty · error
server pushed function exception: %s
Error message
server pushed function exception: %s
What it means
Compiling the server-pushed AsyncFunction (new AsyncFunction(...args, source)) threw an exception. The error is logged and forwarded to wechaty.emitError so the bot can react, and the pushed handler is not installed. It means the source code or argument names sent by the server could not be compiled into a function.
Source
Thrown at src/io.ts:312
}
switch (ioEvent.name) {
case 'botie':
{
const payload = ioEvent.payload
const args = payload.args
const source = payload.source
try {
if (args[0] === 'message' && args.length === 1) {
const fn = new AsyncFunction(...args, source)
this.onMessage = fn
} else {
log.warn('Io', 'server pushed function is invalid. args: %s', JSON.stringify(args))
}
} catch (e) {
log.warn('Io', 'server pushed function exception: %s', e)
this.options.wechaty.emitError(e)
}
}
break
case 'reset':
log.verbose('Io', 'on(reset): %s', ioEvent.payload)
this.options.wechaty.emitError(
new Error(
'reset by server: '
+ JSON.stringify(ioEvent.payload),
),
)
await this.options.wechaty.reset()
break
case 'shutdown':
log.info('Io', 'on(shutdown): %s', ioEvent.payload)View on GitHub (pinned to 5a0520ac7d)
Solutions
- Read the exception in the log ('server pushed function exception: %s') to identify the syntax/compile problem.
- Upgrade wechaty and wechaty-puppet-service to latest so client and server payloads match.
- Subscribe to wechaty error events (bot.on('error')) to capture and diagnose these emitted errors.
- If you control the io server, fix or version the pushed function source it sends.
Example fix
// before
const bot = new Wechaty()
// after
const bot = new Wechaty()
bot.on('error', e => console.error('io push failed:', e)) Defensive patterns
Strategy: try-catch
Try / catch
bot.on('error', (e) => {
if (String(e).includes('server pushed function exception')) {
// degrade gracefully: io push failed, fall back to local handlers
console.error('io pushed function failed to compile:', e)
}
}) Prevention
- Upgrade wechaty so pushed function payloads compile.
- Subscribe to bot error events to observe emitError failures.
- Check network middleboxes that could corrupt WebSocket frames.
When it happens
Trigger: The 'push' branch received a payload whose generated source is syntactically invalid JavaScript, or uses argument names that break AsyncFunction construction (e.g. invalid identifiers) — typically from a server-side protocol/version mismatch.
Common situations: Outdated wechaty client receiving newer pushed-function payloads; proxy/firewall mangling the WS message; io server bugs; tokens routed to an unexpected environment.
Related errors
- server pushed function is invalid. args: %s
- on(jsonrpc) payload is not a jsonrpc request: %s
- UNKNOWN on(%s): %s
- on(jsonrpc) response is undefined.
AI-assisted analysis of wechaty/wechaty@5a0520ac7d (2026-09-01).
Data as JSON: /api/errors/41faa4734d26a276.
Report an issue: GitHub.