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

[bug] not working as in docs described #28

Open
3 tasks done
celevra opened this issue Nov 15, 2024 · 0 comments
Open
3 tasks done

[bug] not working as in docs described #28

celevra opened this issue Nov 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@celevra
Copy link

celevra commented Nov 15, 2024

Describe the bug

Node.js version: v20.18.0

OS version: Ubuntu 20.04

Description: example code does not work it complains

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
const SMTPServer = require('smtp-server').SMTPServer;

const SpamScanner = require('spamscanner');
const scanner = new SpamScanner();

var streamContent = {};
var sessions = {};

const server = new SMTPServer({
    onData(stream, session, callback) {
        sessions[session.id] = {...session}
        stream.on('data', function(d) {
            if (typeof streamContent[session.id] == "undefined") {
                streamContent[session.id] = {}
                streamContent[session.id].msg = d.toString('utf8');
            } else
                streamContent[session.id].msg += d.toString('utf8');
        })
        stream.on('end', function() {
            callback(false)
            process(session.id)
        });
    },
    authOptional: true
});

function process(session) {
    console.log(typeof streamContent[session].msg)
    console.log(streamContent[session].msg)
    scanner.scan(streamContent[session].msg, (err, scan) => {
      if (err) 
        console.error(err);
    });
}

server.listen(20024, function(){
    console.log('running')
});

example result output:

running
string
Received: by mx01.xxxx.com (Postfix, from userid 0)
        id 718F041789; Fri, 15 Nov 2024 17:39:27 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xxxx.com;
        s=mailer; t=;
        bh=g3zLYH4xKxcPrHOD18z9YfpQcnk/GaJedfustWU5uGs=;
        h=Subject:To:Date:From:From;
        b=fwUBTovFAXu1B54QJ1B8M7CcarR0hFprFb6ErjiPmyNmqjV1R9IS0ss29JotVXeJW
         b3CQLh2B/wD7AbvbUNnP8rcvClCLAs97y+35lqw6+ejNsf9qPpSSQ1y3LCM/ionM3H
         Taki7SCMJVVirFKzx+vOGEcaABS1Zvt0jUNVCaeieKAVzD0yKUREcqxnQc0/zkQrCc
         BzV7M4Hg+TW9B4/yiyS+WcELQP9+CNhZF5CtqF92FUCQdepv53ewsneFH6YnuToGfM
         /oDV3MKyJizcP9NO+C1khNC87cM3ZBk/udvpsuNmYbcdtuXNXNdkP7rhdm5ZnodwV8
         VXIRC4WPrwJPA==
Subject: test
To: <philipp@xxxx.com>
X-Mailer: mail (GNU Mailutils 3.7)
Message-Id: <20241115163927.718F041789@mx01.xxxx.com>
Date: Fri, 15 Nov 2024 17:39:27 +0100 (CET)
From: root <root@xxxx.com>

test

node:internal/streams/writable:480
      throw new ERR_INVALID_ARG_TYPE(
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Object
    at _write (node:internal/streams/writable:480:13)
    at Writable.end (node:internal/streams/writable:821:17)
    at Immediate.<anonymous> (/node/postfix/node_modules/nodemailer/lib/mime-node/index.js:977:46)
    at process.processImmediate (node:internal/timers:483:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.18.0

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@celevra celevra added the bug Something isn't working label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant
  NODES
COMMUNITY 2
INTERN 4
Project 5
USERS 1