forwardemail / email-templates

Create, preview (browser/iOS Simulator), and send custom email templates for Node.js. Made for @forwardemail, @ladjs, @cabinjs, @spamscanner, and @breejs.
https://forwardemail.net/docs/send-emails-with-node-js-javascript
MIT License
3.64k stars 339 forks source link

[DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake. #459

Closed bcomnes closed 1 week ago

bcomnes commented 4 months ago

Describe the bug

Node.js version: v21.7.1

OS version: macOS 14.4

Description: Started getting a node DeprecationWarning originating from line: https://github.com/forwardemail/email-templates/blob/e8b8cfced71077a9401f6fd03c6ae8369766978a/index.js#L249

Actual behavior

Test/usage output includes the following deprecation warnings.

(node:60785) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.
    at node:internal/util:431:17
    at new Promise (<anonymous>)
    at node:internal/util:416:12
    at Email.render (/Users/bret/Developer/email-templates/index.js:249:47)
    at async Promise.all (index 2)
    at Email.renderAll (/Users/bret/Developer/email-templates/index.js:263:37)
    at Email.send (/Users/bret/Developer/email-templates/index.js:333:20)
    at async /Users/bret/Developer/email-templates/test/test.js:233:9
(node:60785) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.
    at node:internal/util:431:17
    at new Promise (<anonymous>)
    at node:internal/util:416:12
    at Email.render (/Users/bret/Developer/email-templates/index.js:249:47)
    at async Promise.all (index 1)
    at Email.renderAll (/Users/bret/Developer/email-templates/index.js:263:37)
    at Email.send (/Users/bret/Developer/email-templates/index.js:333:20)
    at async /Users/bret/Developer/email-templates/test/test.js:233:9
  ✔ send two emails with two different locals

Expected behavior

It should avoid running promisify on promise returning functions.

  ✔ send two emails with two different locals

Code to reproduce

Run npm test running on node 21.

Checklist

axelvugts commented 3 months ago

Seeing the same behavior here, would be great if it could be looked into!

ThuanLCSE commented 2 months ago

Same issue in my product, please help to take a look.

titanism commented 1 month ago

Please submit a PR if you'd like to fix this.

bcomnes commented 1 month ago

I may revisit if I find time but anyone else feel free to take a stab at it.

titanism commented 1 week ago

PR welcome