I’m building an automated test for my application but I have a problem with the SFTP Node, I have a Econnereset error on each of my test.
Error: end: read ECONNRESET at Client.fn (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/ssh2-sftp-client/src/utils.js:69:22) at Client.emit (node:events:531:35) at Socket.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/ssh2/lib/client.js:805:12) at Socket.emit (node:events:519:28) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:90:21)
An other problem, when I set up my SFTP credentials, the button test spins indefinitely.
I tested to connect with the sftp client in CLI it works.
I restarted the docker, but I don’t understand why my ftp client is always the same.
I checked the ssh2-sftp-client (10.0.3) and ssh (1.15.0)
Error: end: read ECONNRESET at Client.fn (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/ssh2-sftp-client/src/utils.js:69:22) at Client.emit (node:events:531:35) at Socket.<anonymous> (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/[email protected]/node_modules/ssh2/lib/client.js:805:12) at Socket.emit (node:events:519:28) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:90:21)
Thank you for providing the credentials to your sftp server for tests. You are right, the previous approach wasn’t a success, because of some module locations. Here is what worked for me:
Shell into n8n container:
# Root shell
docker exec -u root -it n8n bash
Do some magic:
# 1) Build the pinned packages in isolation
rm -rf /tmp/pin && mkdir -p /tmp/pin && cd /tmp/pin
npm init -y >/dev/null 2>&1
npm i [email protected][email protected] --no-audit --no-fund
# 2) Find the active pnpm node_modules directories used by n8n
PNPM_DIR=/usr/local/lib/node_modules/n8n/node_modules/.pnpm
SFTP_NODEMODS="$(ls -d $PNPM_DIR/ssh2-sftp-client@*/node_modules | head -n1)"
SSH2_NODEMODS="$(ls -d $PNPM_DIR/ssh2@*/node_modules | head -n1)"
# Safety check
test -d "$SFTP_NODEMODS" && test -d "$SSH2_NODEMODS" || { echo "pnpm paths not found"; exit 1; }
# 3) Replace the package folders
rm -rf "$SFTP_NODEMODS/ssh2-sftp-client" "$SSH2_NODEMODS/ssh2"
cp -r node_modules/ssh2-sftp-client "$SFTP_NODEMODS/"
cp -r node_modules/ssh2 "$SSH2_NODEMODS/"
# 4) Copy direct deps of ssh2-sftp-client AND of promise-retry (the one complaining about err-code)
copy_dep () {
local dep="$1"
if [ -d "node_modules/$dep" ]; then
rm -rf "$SFTP_NODEMODS/$dep"
cp -r "node_modules/$dep" "$SFTP_NODEMODS/"
fi
}
# Direct deps of [email protected]
for d in $(node -p "Object.keys(require('./node_modules/ssh2-sftp-client/package.json').dependencies||{}).join(' ')"); do
copy_dep "$d"
done
# Direct deps of promise-retry (pulls in err-code, retry, etc.)
for d in $(node -p "Object.keys(require('./node_modules/promise-retry/package.json').dependencies||{}).join(' ')"); do
copy_dep "$d"
done
# 5) Fix ownership
chown -R node:node "$SFTP_NODEMODS/ssh2-sftp-client" "$SSH2_NODEMODS/ssh2" "$SFTP_NODEMODS"/*
# 6) Verify (should print 10.0.3 and 1.15.0)
node -p "require('$SFTP_NODEMODS/ssh2-sftp-client/package.json').version"
node -p "require('$SSH2_NODEMODS/ssh2/package.json').version"
exit