waha icon indicating copy to clipboard operation
waha copied to clipboard

[NOWEB] - /api/sendImage ERROR

Open Andrea-1976 opened this issue 8 months ago • 2 comments

When I try to send a text with an image I get the error "user_agents_1.default is not a constructor". The problem started with the new version 2026.3.1

/api/sendImage

{ "statusCode": 500, "timestamp": "2026-03-05T08:57:16.581Z", "exception": { "message": "user_agents_1.default is not a constructor", "name": "TypeError", "stack": "TypeError: user_agents_1.default is not a constructor\n at fetchBuffer (/app/dist/utils/fetch.js:11:23)\n at WhatsappSessionNoWebPlus.fetch (/app/dist/core/abc/session.abc.js:671:40)\n at WhatsappSessionNoWebPlus.fileToMessage (/app/dist/plus/engines/noweb/session.noweb.plus.js:59:34)\n at WhatsappSessionNoWebPlus.sendImage (/app/dist/plus/engines/noweb/session.noweb.plus.js:126:36)\n at descriptor.value (/app/dist/core/abc/activity.js:9:35)\n at process.processTicksAndRejections (node:internal/process/task_queues:103:5)" }, "request": { "path": "/api/sendImage/", "method": "POST", "body": { "file": { "mimetype": "image/jpeg", "url": "https://storage.googleapis.com/msgsndr/image.jpeg" }, "chatId": "[email protected]", "session": "session_01", "caption": "Text message" }, "query": {} }, "version": { "version": "2026.3.1", "engine": "NOWEB", "tier": "PLUS", "browser": null, "platform": "linux/x64", "worker": { "id": "WAHA2" } } }

Version

WAHA-PLUS 2026.3.1

Andrea-1976 avatar Mar 05 '26 10:03 Andrea-1976

That fix got it working fine again for me @devlikepro

index a197dbfa..c16f146a 100644
--- a/src/utils/fetch.ts
+++ b/src/utils/fetch.ts
@@ -1,11 +1,8 @@
 import axios from 'axios';
 import { Agent as HttpsAgent } from 'https';
-import * as UserAgentsModule from 'user-agents';
 
 // user-agents exports the constructor directly (no .default) in CommonJS
-const UserAgent =
-  (UserAgentsModule as { default?: new () => { toString(): string } }).default ??
-  (UserAgentsModule as new () => { toString(): string });
+const UserAgent = require('user-agents') as new () => { toString(): string };
 
 const InsecureHttpsAgent = new HttpsAgent({
   rejectUnauthorized: false,```

[![patron:PRO](https://img.shields.io/badge/patron-PRO-188a42)](https://waha.devlike.pro/docs/how-to/plus-version/#tiers)

motammi avatar Mar 05 '26 10:03 motammi

https://github.com/devlikeapro/waha/commit/393f5ef7da5db3751baf5a955220d076afcd9165

2026.3.2

patron:PRO

devlikepro avatar Mar 05 '26 10:03 devlikepro