Closed jmd9019 closed 2 years ago
Hey @jmd9019, thanks for using serverless-adapter.
Some questions:
Yes I am using NPM and i am using VS Code as IDE and my PC is windows. Also I am trying to deploy on DO functions
And to be clear, as of now I am just deploying to DO's function and try to send get GET request to URL provided by DO's function
Maybe the problem is with Windows, @h4ad/node-modules-packer
may not be able to bundle the @h4ad/serverless-adapter
library.
To test, zip the dist
folder and the node_modules
folder into a file called deploy.zip
, then move this zip folder to packages/api/prod
and replace the zip that was there.
Then run npm run update-function
to update your code inside the DO.
Also, inside package.json
, did you change the @h4ad/serverless-adapter
for @h4ad/node-modules-packer
or is just a typo issue in your description here "I added npm package instead of file link in package.json "@h4ad/node-modules-packer": "^1.1.0",
".
If you changed, this could be the issue too, inside package.json
, in production dependencies, you must have @h4ad/serverless-adapter
version 2.10.0
at least.
I think its correctly creating deploy.zip I looked into zip file It had 2 file node_modules and dist which has the code
Here's the dependencies inside package.json
"dependencies": {
"@h4ad/node-modules-packer": "^1.1.0",
"@h4ad/serverless-adapter": "^2.10.0",
"@trpc/server": "9.27.0",
"zod": "^3.18.0"
},
I think its correctly creating deploy.zip I looked into zip file It had 2 file node_modules and dist which has the code
Look inside node_modules, there is a @h4ad
folder and inside it is serverless-adapter
.
Ok inside deploy.zip in node_modules there is no folder @h4ad but in my PC's node_modules there is @h4ad folder
I will try this https://github.com/H4ad/serverless-adapter-examples/issues/2#issuecomment-1242976900 and see if I can make some progress
Hi @H4ad , I did it manually now creating deploy.zip and used npm run update-function. Still there is error I am sending GET request to '/getUser'
export const appRouter = trpc
.router<TrpcContext>()
.transformer(new BufferToJSObjectTransformer())
.query('getUser', {
async resolve() {
return { name: 'Bilbo' };
},
})
Getting error as "2022-09-11T15:16:26.332147Z stderr: The action did not initialize or run as expected. Log data might be missing."
When you call the API inside DO, you should add the prefix of your folders inside package, so instead /getUser
, you call /api/prod/getUser
.
Let's just summarize:
deploy.zip
with the dist
and node_modules
folders.deploy.zip
inside packages/api/prod
with the zip file you created.npm run update-function
.About the code, did you change anything? Because these errors sound like something related to the tRPC code.
What about project.yml
, did you change anything in the example?
Are you receiving any logs inside DO?
Yes did follow all 3 points About code nothing is changed also nothing is changed on project.yml
packages:
- name: api
functions:
- name: 'prod'
main: 'dist/index.main'
runtime: 'nodejs:18'
web: 'raw'
DO logs under logs tab
"logs":[
0:"2022-09-11T15:56:52.996200Z stderr: The action did not initialize or run as expected. Log data might be missing."
]
"response":{
"result": {
"error": "The action exceeded its time limits of 10000 milliseconds during initialization."
},
"size": null,
"status": "action developer error",
"success": false
}
Strange, very strange, everything seems fine.
Try using this zip folder to deploy, I created it using linux and running @h4ad/node-modules-packer
:
deploy.zip
If it works, try to see if there are any differences between the files inside dist
or see if any dependencies are missing inside node_modules
.
Yes, your deploy.zip is working but I don't see any packages missing in my deploy (2).zip
But has some extra packages
Try removing typescript
, esbuild-windows-64
and yarn
from your node_modules
inside your deploy.zip
and then deploy again.
Also, do you have WSL? If so, try deploying inside WSL, I think it's a bug in node-modules-packer
on Windows and some issue with the size of the zip.
Try removing typescript, esbuild-windows-64 and yarn from your node_modules inside your deploy.zip and then deploy again.
I removed these files and redeployed now its working
I don't have WSL as my PC SSD is running out of space
I will try to fix the issue of packing inside Windows in node-modules-packer
, but until then, you will need to pack your files manually and remove typescript
and esbuild-windows-64
.
The issue with the size is probably issue on DO but this thing we can't control.
Sure, I will remove it manually as of now, also can this be also fixed https://github.com/H4ad/serverless-adapter-examples/issues/2#issuecomment-1242977984 node-modules-packer was missing out modules which had folder names starting with @ on my PC
Thanks for the help,
Hey @jmd9019, I release a new version of @h4ad/node-modules-packer
, try running again with it to see if now works.
Hi @H4ad, I tried "@h4ad/node-modules-packer": "^1.2.1" on windows now it's deploying correctly. Thanks for the help.
Nice man, thanks for using it and reporting this bug.
Hi @H4ad , I was trying https://github.com/H4ad/serverless-adapter-examples/tree/master/examples/trpc-digital-ocean to deploy to digital ocean functions I added npm package instead of file link in package.json "@h4ad/node-modules-packer": "^1.1.0", I was able to deploy correctly but when I click run on DO functions I am getting error