You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to run Deno in Google Cloud Run and while I could get my code to run locally using Docker, I kept getting the same error when trying to run in Cloud Run.
The errors I received in Cloud Run are (may be a bit messed up, I tried unescaping the logs):
error: Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum
at Object.jsonOpSync (core.js:247:13)
at opListen ($deno$/cli/rt/30_net.js:32:17)
at Object.listen ($deno$/cli/rt/30_net.js:207:17)
at serve (server.ts:287:25)
at file:///app/src/index.js:22:16
My Dockerfile is:
FROM hayd/alpine-deno
WORKDIR /app
USER deno
EXPOSE $PORT
COPY . .
RUN deno cache src/index.js
CMD ["run", "--allow-net", "--allow-env", "src/index.js"]
This Dockerfile worked fine locally but I got an error when using in CloudRun. I was able to resolve the error by changing the argument to serve() to a string, like this:
// results in errorconstserver=serve({hostname: HOST,port: PORT});// results in errorconstserver=serve({port: PORT});// worksconstserver=serve(`${HOST}:${PORT}`);
I'm not sure quite what's happening, but it appears the validation is failing when passing in an object as the argument with the same data as the string.
From digging around in the source, it seems like this may be where the error is coming from.
Theory: The biggest difference between Cloud Run and my local setup is that Cloud Run pulls the value of PORT from an environment variable, which makes it a string, whereas my fallback value is a number (used locally). So, my guess is that somewhere in Deno, there is code expecting a number for the port, and when that check fails, this error occurs. I don't have the time to look at this further tonight but I can check tomorrow.
The text was updated successfully, but these errors were encountered:
which makes it a string, whereas my fallback value is a number (used locally). So, my guess is that somewhere in Deno, there is code expecting a number for the port, and when that check fails, this error occurs
This is exactly what I am thinking too. This could definitely use a more helpful error message.
Just verified: indeed it is the case that if PORT is a string, I get this error. 👍 to having a better error message, though it seems like this could be addressed by converting to a number if the port value is not a number (Express does this, afaik).
If anyone could point me in the right direction, I'd be happy to investigate and see if I can come up with a solution. Where could I start looking for where this error might be occurring?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I've been trying to run Deno in Google Cloud Run and while I could get my code to run locally using Docker, I kept getting the same error when trying to run in Cloud Run.
Code:
The errors I received in Cloud Run are (may be a bit messed up, I tried unescaping the logs):
My Dockerfile is:
This Dockerfile worked fine locally but I got an error when using in CloudRun. I was able to resolve the error by changing the argument to
serve()to a string, like this:I'm not sure quite what's happening, but it appears the validation is failing when passing in an object as the argument with the same data as the string.
From digging around in the source, it seems like this may be where the error is coming from.
Theory: The biggest difference between Cloud Run and my local setup is that Cloud Run pulls the value of
PORTfrom an environment variable, which makes it a string, whereas my fallback value is a number (used locally). So, my guess is that somewhere in Deno, there is code expecting a number for the port, and when that check fails, this error occurs. I don't have the time to look at this further tonight but I can check tomorrow.The text was updated successfully, but these errors were encountered: