{"record":{"id":"41faa4734d26a276","repo":"wechaty/wechaty","slug":"server-pushed-function-exception-s","errorCode":null,"errorMessage":"server pushed function exception: %s","messagePattern":"server pushed function exception: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/io.ts","lineNumber":312,"sourceCode":"    }\n\n    switch (ioEvent.name) {\n      case 'botie':\n        {\n          const payload = ioEvent.payload\n\n          const args   = payload.args\n          const source = payload.source\n\n          try {\n            if (args[0] === 'message' && args.length === 1) {\n              const fn = new AsyncFunction(...args, source)\n              this.onMessage = fn\n            } else {\n              log.warn('Io', 'server pushed function is invalid. args: %s', JSON.stringify(args))\n            }\n          } catch (e) {\n            log.warn('Io', 'server pushed function exception: %s', e)\n            this.options.wechaty.emitError(e)\n          }\n        }\n        break\n\n      case 'reset':\n        log.verbose('Io', 'on(reset): %s', ioEvent.payload)\n        this.options.wechaty.emitError(\n          new Error(\n            'reset by server: '\n            + JSON.stringify(ioEvent.payload),\n          ),\n        )\n        await this.options.wechaty.reset()\n        break\n\n      case 'shutdown':\n        log.info('Io', 'on(shutdown): %s', ioEvent.payload)","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/wechaty/wechaty/blob/5a0520ac7d0567777d6931eee53f81bbfcae1453/src/io.ts#L294-L330","documentation":"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.","triggerScenarios":"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.","commonSituations":"Outdated wechaty client receiving newer pushed-function payloads; proxy/firewall mangling the WS message; io server bugs; tokens routed to an unexpected environment.","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."],"exampleFix":"// before\nconst bot = new Wechaty()\n// after\nconst bot = new Wechaty()\nbot.on('error', e => console.error('io push failed:', e))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"bot.on('error', (e) => {\n  if (String(e).includes('server pushed function exception')) {\n    // degrade gracefully: io push failed, fall back to local handlers\n    console.error('io pushed function failed to compile:', e)\n  }\n})","preventionTips":["Upgrade wechaty so pushed function payloads compile.","Subscribe to bot error events to observe emitError failures.","Check network middleboxes that could corrupt WebSocket frames."],"tags":["websocket","io","eval","protocol"],"backgroundTag":"io-protocol-mismatch","analyzedSha":"5a0520ac7d0567777d6931eee53f81bbfcae1453","analyzedAt":"2026-09-01T01:57:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}