mafredri / zsh-async

Because your terminal should be able to perform tasks asynchronously without external tools!
MIT License
766 stars 34 forks source link

Max argument size of around 1000 chars #68

Open hansbogert opened 11 months ago

hansbogert commented 11 months ago

There seems to be a max argument size which causes zsh-async to just silently error:

function foobar()
{
  echo $1
}

source ~/.zsh-async/async.zsh
async_init

# Initialize a new worker (with notify option)
async_start_worker my_worker -n

# Create a callback function to process results
completed_callback() {
  echo $@
}

# Register callback function for the workers completed jobs
async_register_callback my_worker completed_callback

# Give the worker some tasks to perform
async_job my_worker foobar $(i=0; while [ $i -lt 1000 ]; do echo -n "1"; i=$((i+1)); done)

sleep 1

Maybe it's platform dependent, so please increase if you still see the $@ output from the callback. If you hit the error, you will not see the $@ output in the callback.

hansbogert commented 11 months ago

I noticed the more-zpty-fixes branch, it does not resolve the issue for me.

hansbogert commented 11 months ago

I found a workaround for my specific issue. My issue was that I needed to send a large environment variable value as parameter, because it can change. My workaround for now is to recognize the environment value is changed during a callback, if so, restart the worker. The worker's environment is then the same as the main environment.