tus / tusd

Reference server implementation in Go of tus: the open protocol for resumable file uploads
https://tus.github.io/tusd
MIT License
3.03k stars 474 forks source link

Hooks are not being invocated #1186

Open jeqermigselv-cloud opened 5 days ago

jeqermigselv-cloud commented 5 days ago

Describe the bug Despite having enabled hooks, no hooks are sent. This is confirmed both in the log of tusd, but also on the recieving server, that hasn't recieved any requests.

To Reproduce Steps to reproduce the behavior:

  1. Start the docker image with the args provided in the below section.
  2. Start upload
  3. Observe that the response is sent without the hook invocated
Stream Log
stdout 2024/09/14 12:54:58.497060 Using Azure endpoint https://[_NAME_].blob.core.windows.net.
stdout 2024/09/14 12:54:58.610792 Using 19.07MB as maximum size.
stdout 2024/09/14 12:54:58.610815 Using 'https://[`URL`]' as the endpoint for hooks
stdout 2024/09/14 12:54:58.610859 Enabled hook events: pre-create, pre-finish
stdout 2024/09/14 12:54:58.610867 Supported tus extensions: creation,creation-with-upload,termination,creation-defer-length
stdout 2024/09/14 12:54:58.610870 Using 0.0.0.0:8080 as address to listen.
stdout 2024/09/14 12:54:58.610873 Using /files/ as the base path.
stdout 2024/09/14 12:54:58.610926 Using /metrics as the metrics path.
stdout 2024/09/14 12:54:58.611172 You can now upload files to: http://[::]:8080/files/
stdout 2024/09/14 12:55:08.197593 level=INFO event=RequestIncoming method=HEAD path=49e15f752aa505a9c1efa58b9e0ca360 requestId=4de664da-ad62-4309-885a-5ea9b03eba87
stdout 2024/09/14 12:55:08.197593 level=INFO event=RequestIncoming method=HEAD path=a38d7352c7181d9e74cf3bff813aefb1 requestId=8fca14e9-0907-430b-8786-9c8e67a18962
stdout 2024/09/14 12:55:08.197703 level=INFO event=RequestIncoming method=HEAD path=16e2ea0141adb9de4198f6f0422c2cdb requestId=d7fe2515-af13-4a6b-8309-e5afd4ba2c26
stdout 2024/09/14 12:55:08.198128 level=INFO event=RequestIncoming method=HEAD path=15551e470b80a0eae096809e45344954 requestId=52d78aa7-d5fc-4018-90b0-d670eee43c40
stdout 2024/09/14 12:55:08.199096 level=INFO event=RequestIncoming method=HEAD path=89a537a3a4e33748abeca00dfe056137 requestId=67c7f922-325d-41bf-a664-c4f4eda643cf
stdout 2024/09/14 12:55:08.221793 level=INFO event=ResponseOutgoing method=HEAD path=49e15f752aa505a9c1efa58b9e0ca360 requestId=4de664da-ad62-4309-885a-5ea9b03eba87 id=49e15f752aa505a9c1efa58b9e0ca360 status=200 body=""
stdout 2024/09/14 12:55:08.225026 level=INFO event=ResponseOutgoing method=HEAD path=16e2ea0141adb9de4198f6f0422c2cdb requestId=d7fe2515-af13-4a6b-8309-e5afd4ba2c26 id=16e2ea0141adb9de4198f6f0422c2cdb status=200 body=""
stdout 2024/09/14 12:55:08.228080 level=INFO event=ResponseOutgoing method=HEAD path=89a537a3a4e33748abeca00dfe056137 requestId=67c7f922-325d-41bf-a664-c4f4eda643cf id=89a537a3a4e33748abeca00dfe056137 status=200 body=""
stdout 2024/09/14 12:55:08.230748 level=INFO event=ResponseOutgoing method=HEAD path=15551e470b80a0eae096809e45344954 requestId=52d78aa7-d5fc-4018-90b0-d670eee43c40 id=15551e470b80a0eae096809e45344954 status=200 body=""
stdout 2024/09/14 12:55:08.230893 level=INFO event=ResponseOutgoing method=HEAD path=a38d7352c7181d9e74cf3bff813aefb1 requestId=8fca14e9-0907-430b-8786-9c8e67a18962 id=a38d7352c7181d9e74cf3bff813aefb1 status=200 body=""
Expected behavior It is expected that the hooks are being called, and that is logged, i.e.: 2024/09/14 12:18:53.345959 level=DEBUG event=HookInvocationStart type=pre-create id=""
2024/09/14 12:18:57.472757 level=DEBUG event=HookInvocationFinish type=pre-create id=""

Setup details Please provide following details, if applicable to your situation:

jeqermigselv-cloud commented 5 days ago

Oh, it seems like it is only invocated if the user is uploading new images!

Acconut commented 3 days ago

The pre-create and pre-finish hooks are only invoked if a new upload is started and finished, respectively. The logs indicate that that Uppy is only sending HEAD requests, which doesn't start or finish a new upload, but checks the state of a previous upload. That's why the hooks were not invoked.

Uppy is probably configured to not upload a file if it has already been uploaded. It's best to tweak Uppy's configuration to get the upload behavior you want.