SamKirkland / ftp-deploy

Deploy websites over FTP with one command line
MIT License
89 stars 43 forks source link

Better timeout support: `.ftp-deploy-sync-state.json` model / early generation, number of files / folders to sync... #34

Open DamChtlv opened 1 year ago

DamChtlv commented 1 year ago

I'm having an issue where after some time creating folders / files, the action stop working (seems to freeze) and finally resolve to this: Error: Timeout (control socket)

My config:

- name: 📁 Sync files
      uses: SamKirkland/FTP-Deploy-Action@v4.3.4
      with:
        server: XXX
        username: XXX
        password: ${{ secrets.PREPROD_FTP_PASS }}
        local-dir: ./wp-content/themes/val/
        server-dir: ./autodeploytest/
        timeout: 150000

Log representation:

----------------------------------------------------------------
🚀 Thanks for using ftp-deploy. Let's deploy some stuff!   
----------------------------------------------------------------
If you found this project helpful, please support it
by giving it a ⭐ on Github --> https://github.com/SamKirkland/FTP-Deploy-Action
or add a badge 🏷️ to your projects readme --> https://github.com/SamKirkland/FTP-Deploy-Action#badge
----------------------------------------------------------------
No file exists on the server "./autodeploytest/.ftp-deploy-sync-state.json" - this must be your first publish! 🎉
The first publish will take a while... but once the initial sync is done only differences are published!
If you get this message and its NOT your first publish, something is wrong.
----------------------------------------------------------------
Local Files:    340
Server Files:   0
----------------------------------------------------------------
Calculating differences between client & server
----------------------------------------------------------------

📁 Create: ... (a lot)
📄 Upload: ... (a lot)

----------------------------------------------------------------
Making changes to 340 files/folders to sync server state
Uploading: 4.97 MB -- Deleting: 0 B -- Replacing: 0 B
----------------------------------------------------------------

creating folder "..." (some)
uploading "..." (some)

...then at one point, it freeze here i don't know why...
and after the specific timeout, it finally resolve to this:

----------------------------------------------------------------
--------------  🔥🔥🔥 an error occurred  🔥🔥🔥  --------------
----------------------------------------------------------------

----------------------------------------------------------------
----------------------  full error below  ----------------------
----------------------------------------------------------------

Error: Timeout (control socket)
    at Socket.<anonymous> (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/v4.3.4/dist/index.js:5288:33)
    at Object.onceWrapper (node:events:627:28)
    at Socket.emit (node:events:513:28)
    at Socket._onTimeout (node:net:550:8)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)
Error: Error: Timeout (control socket)

The problem is that it starts over from the beginning if i trigger it again, so zero progress.
I tried changing default timeout value from 120000 to 15000, but it always result in timeout error.

It would be nice to have an option to create .ftp-deploy-sync-state.json before a timeout occurs so it can actually make progress (like one second before set timeout)
Or to be able to set a number of files / folders to sync so it stops after this number and generate .ftp-deploy-sync-state.json to store progress. Or even have a .ftp-deploy-sync-state.json model / template, so we can see how it is structured and create it ourselves on the server so it can resume where it stopped previously

markparnell commented 1 year ago

Having a very similar issue here - it runs for around 20 minutes and successfully uploads several hundred files and folders before returning an error:

----------------------------------------------------------------
----------------------  full error below  ----------------------
----------------------------------------------------------------

FTPError: 425 Unable to build data connection: Operation not permitted
    at FTPContext._onControlSocketData (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/v4.3.4/dist/index.js:5252:39)
    at TLSSocket.<anonymous> (/home/runner/work/_actions/SamKirkland/FTP-Deploy-Action/v4.3.4/dist/index.js:5096:44)
    at TLSSocket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:285:11)
    at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
  code: 425
}
Error: FTPError: 425 Unable to build data connection: Operation not permitted

Having the ability for it to update the state after every N files or something would be really handy. In our case it would also be helpful if we could flag what commit the remote is up to, as we are migrating from a different system and don't need it to upload anything initially, but that's a separate issue.