Problem executing JavaScript code

ok… potential issues:
If your stack isn’t named n8n, then n8n_n8n_worker won’t resolve. Check what docker service ls shows and match the URI accordingly.
There’s a community report indicating that in n8n 2.x, external task runners should connect to the main instance (editor), not the worker. The main instance acts as the task broker. Try pointing your runner to the editor instead

Can you share the output of docker service logs <your_runner_service>? That will show whether the runner is failing to connect, getting auth errors, or never reaching the broker at all.