Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem: When an action author exits an action via
process.exit
, the standard out and standard error buffers may still have data yet-to-be-logged in them. This causes logs to be lost, as a user expects to be able to do this:Since
process.stdout.write
is async andprocess.exit
is sync, not all of what's passed to standard out in that script may be logged.Current solution: An action author can log a special string to standard out that tells the Actions runtime whether the action was successful, neutral, or a failure.
Proposed solution: Add an
exit
package that users are encouraged to make use of for ending their actions. This package has async functions which drain standard out and standard error before finally exiting. Since users are encouraged to write actions withinToolkit.run
, which is async, it is easy to write code that reads much like code that usesprocess.exit
:If an immediate exit is required, the user can pass a
sync
option (e.g.tools.exit.failure({ sync: true })
).These functions are also exposed independently in the
@actions/exit
package:Question: This relies on the
bufferSize
property fromnet.Socket
(which is aWriteStream
). This will only be present if standard out and standard error are TTYs in the Actions runtime (and not, for example, a file).