Open williamsdyyz opened 2 months ago
Do you end/finish your target stream when it's done?
@patrickjuchli having the same issue. It was working few weeks ago, now the request times out. Here is my code:
const client = new Client();
client.ftp.verbose = false;
await client.access({
host: "MY-HOST-IP",
user: "MY-HOST-USER",
password: "MY-HOST-PASSWORD",
});
const stream = new PassThrough();
#THIS IS WHERE IT HANGS FOREVER
await client.downloadTo(stream, "compatta.xml");
let data = "";
const streamPromise = new Promise((resolve, reject) => {
stream.on("data", (chunk) => {
data += chunk;
});
stream.on("end", () => {
const result = convert.xml2json(data, {
compact: true,
spaces: 2,
ignoreDeclaration: true,
});
resolve(result);
});
stream.on("error", (error) => {
reject(error);
});
});
Do you end/finish your target stream when it's done?
You mean the last stream in the pipeline? No. Everything in the pipeline is a 3rd party NPM package. I just consume the result with on("data"...
@jimmysafe, there hasn't been a new release in the last weeks or months. Do you know which last version worked on your end?
I'm getting the same issue here with slightly larger files, around 15mb to 20mb but for me it happens during upload.
Downloading a zip file to a stream. The stream pipeline then unzips and processes the data which takes 2-3 minutes.
What I'm seeing is a successful connection and the zip file downloads quickly. Then while the rest of the pipeline is still processing, error happens and the end of the stream seems to be corrupted.
This happens with the 3rd party FTP server I'm trying to access and also with my local FileZilla test server.
Example code
This code fails with the socket error and the stream data is corrupted. The exact same code with a local file stream works.
Console output
Which version of Node.js are you using? 20.5.1
Which version of basic-ftp are you using? 5.0.5
Additional context The FTP server is not in my control. All I know is "Microsoft FTP Service" My project is based on @google-cloud/functions-framework to be deployed as a cloud function. I'm using the stream-chain package to simplify stream handling. I tried a regular node pipeline with the same result.
Additional info after further investigation The issue seems happen when basic-ftp is used with unzipper. When I switched out unzipper for zlib (and changed to a .gz file) everything works as expected.
I'm using unzipper like this
const unzipStream = ParseOne(/^FILE.zip$/)
It's unclear whether this is a basic-ftp issue or not. All I can say is I've used unzipper successfully with ssh2-sftp-client