Shell script: redirect operator "|" seems executing in Asynchronous way

When execute this shell command(the js file needs time to execute(network i/o)), keyboard maestro immediately update my clipboard with 1 record(0 character). In terminal, this command works fine and give me correct result in clipboard.

This command works fine in keyboard maestro.

So, does keyboard maestro execute pipe shell command in asynchronous way? How to solve the problem that keyboard maestro immediately update the clipboard with 1 record(0 character)?

To be clear, in the action you show, Keyboard Maestro does not touch your clipboard. The script updates your clipboard.

Keyboard Maestro does not affect how pipes are processed, or the behaviour of the pbcopy tool.

So my guess is the issue has nothing to do with either of those, and instead is an issue with the node command, probably related to the different environment in Keyboard Maestro and the Terminal. What happens if the change the action to display the results in a window, and remove the “| pbcopy” - what result is displayed in the window.

If you search the forum for shell environment you will find various topics discussing issues people have encountered when faces with the different environment variables configured in the Terminal and in Keyboard Maestro and a variety of solutions.

BTW, you don't really need the | pbcopy in this case, since the Execute a Shell Script action can put the output directly to the clipboard itself.