#Cancel a running Build
1 messages · Page 1 of 1 (latest)
hey! if you press ctrl+c (SIGTERM) when the pipeline is running, it should cancel it
Hello 🙂 Yes this works but is there a way to cancel it pragmatically?
yes, which SDK are you using?
oh, I see node
hmm in Go this is possible via context cancellations, not sure if that's possible with the promises and async/await functions in Node and Python. Any clues @vapid tree @tulip rain ?
I don't think you with native typescript, there are severals issues about that on stack overflow: https://stackoverflow.com/questions/70080967/proper-way-to-abort-stop-running-async-await-function
What is your use case? May we can find a workaround
We run automated builds and have a UI where developers can manage their builds and we would like to give the option to cancel a build.
If one takes too long and blocks new ones to use the resources
@woeful raft @tulip rain maybe one way to achieve this could be to start the dagger pipeline via a fork call and then just send a kill message whenever you want to stop it. I'd think that should work ok. Not sure if you've made any progress here @woeful raft !
Yeah that's a solution, no matter what you do, you'll need either a wrapper aounrd async/await or around the process you run
The fork approach seems good to me I will test that. Would something like p-timeout also work or dose this just stop awaiting the promise after the timeout.
https://www.npmjs.com/package/p-timeout
yes, this won't work unfortunately since the promise will still keep executing after the timeout is hit "unless" your program exists right after that
it really depends on how you're triggering your build. I
What happens when we reject the „parent“ promise using token cancellation (https://stackoverflow.com/a/30235261 )? Would dagger stop building?
@woeful raft
the thing about the token cancellation approach is that you need to have a way to abort whatever you're doing in the first place. In the example listed in the article, the user is calling xhr.abort. In dagger there's no such method in the SDK.
Oh I see. I also saw that this wouldn’t stop the dagger build, it would just discard the promise. We‘ll try your suggestion with fork and kill. Thank you!
We tried some stuff with fork but this does not feel really clean because we can only start files. Do you know of library that can start a function in a sub process? We tried serializing the function and passing it via IPC to the child process where it was deserialized but we could not import the dagger sdk from there.
why instead of trying to serialize the function you define it in the sub-process file and then you just send the function name and the arguments to simply call it?
this way you won't find yourself in this situation of trying to implement an RPC style thing
Do you know of library that can start a function in a sub process?E
I haven't personally seen any
so then you can do something like fork("myfile.js", ["build", "arg1", "arg2"]...)
