Skip to content

Commit

Permalink
fix: fixes "url" argument must be of type string with nodejs 20
Browse files Browse the repository at this point in the history
node:internal/errors:541
      throw error;
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at Url.parse (node:url:170:3)
    at Object.urlParse [as parse] (node:url:141:13)
    at new FtpServer (C:\work\xemu\xemu-bsp-list\ftp-srv\src\index.js:34:24)
    at startFtpServer (C:\work\xemu\xemu-bsp-list\ftp-srv\bin\index.js:133:21)
    at Object.<anonymous> (C:\work\xemu\xemu-bsp-list\ftp-srv\bin\index.js:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1369:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.12.0
  • Loading branch information
lygstate committed Aug 24, 2024
1 parent 89bd13d commit 42d4a2d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class FtpServer extends EventEmitter {
greeting: null,
tls: false,
timeout: 0
}, options);

}, _.pickBy(options, v => v !== undefined));
this._greeting = this.setupGreeting(this.options.greeting);
this._features = this.setupFeaturesMessage();

Expand All @@ -52,7 +51,7 @@ class FtpServer extends EventEmitter {
socket.once('close', () => {
this.emit('disconnect', {connection, id: connection.id, newConnectionCount: Object.keys(this.connections).length});
})

this.emit('connect', {connection, id: connection.id, newConnectionCount: Object.keys(this.connections).length});

const greeting = this._greeting || [];
Expand All @@ -67,7 +66,7 @@ class FtpServer extends EventEmitter {
this.log.error(err, '[Event] error');
this.emit('server-error', {error: err});
});

const quit = _.debounce(this.quit.bind(this), 100);

process.on('SIGTERM', quit);
Expand Down Expand Up @@ -138,7 +137,7 @@ class FtpServer extends EventEmitter {
} catch (err) {
this.log.error(err, 'Error closing connection', {id});
}

resolve('Disconnected');
});
}
Expand Down

0 comments on commit 42d4a2d

Please sign in to comment.