Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this._socket.removeListener is not a function #20571

Closed
ry opened this issue Sep 19, 2023 · 6 comments
Closed

this._socket.removeListener is not a function #20571

ry opened this issue Sep 19, 2023 · 6 comments
Assignees

Comments

@ry
Copy link
Member

ry commented Sep 19, 2023

This has come up with npm:nodemailer. See this comment #18303 (comment)

@littledivy
Copy link
Member

littledivy commented Sep 21, 2023

I get the same error in Node.js as well, cc @dehrhard

/Users/divy/gh/node_modules/.deno/nodemailer@6.9.4/node_modules/nodemailer/lib/smtp-connection/index.js:896
        this._socket.removeListener('data', this._onSocketData); // incoming data is going to be gibberish from this point onwards
                     ^

TypeError: this._socket.removeListener is not a function
    at SMTPConnection._upgradeConnection (/Users/divy/gh/node_modules/.deno/nodemailer@6.9.4/node_modules/nodemailer/lib/smtp-connection/index.js:896:22)
    at Immediate.<anonymous> (/Users/divy/gh/node_modules/.deno/nodemailer@6.9.4/node_modules/nodemailer/lib/smtp-connection/index.js:246:26)
    at process.processImmediate (node:internal/timers:478:21)

Maybe a bug in nodemailer?

@dehrhard
Copy link

Hmm why do you think it's a bug in nodemailer? Isn't removeListener a method of socket and shouldn't that be provided by the deno compatibility layer?

@littledivy
Copy link
Member

littledivy commented Sep 21, 2023

this._socket is not the net.Socket object when this code path is executed. You can try the exact same code in Node.js and it still errors.

@littledivy
Copy link
Member

littledivy commented Sep 21, 2023

Oh, the reproduction code does not pass the connection option correctly, the error is gone with this change:

const connection = {
  from: "test@test.com",
  host: "host.host.com",
  port: 587,
  auth: {
    user: "123",
    pass: "456",
  },
};

const smtpClient = createTransport({
- connection,
+ ...connection,
  secure: true,
});

@dehrhard
Copy link

Oh dang, you're right. Looks like I have been misinterpreting the property. Looks like it is actually used for socket configuration which explains a lot
image
I'll try it out and see if it works.

@dehrhard
Copy link

dehrhard commented Sep 21, 2023

Hey, I can confirm this works now. I knew it was something stupid 😄 Thanks, and again. Great work.

@ry ry closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants