Giter Club home page Giter Club logo

Comments (24)

jmd9019 avatar jmd9019 commented on June 19, 2024 1

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"
  },

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

Hey @jmd9019, thanks for using serverless-adapter.

Some questions:

  • Did you use NPM?
  • Are you deploying inside Windows or Linux?

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

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

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

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

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

I think its correctly creating deploy.zip I looked into zip file It had 2 file node_modules and dist which has the code

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

Ok inside deploy.zip in node_modules there is no folder @H4ad but in my PC's node_modules there is @H4ad folder

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

I will try this #2 (comment) and see if I can make some progress

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

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."

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

This the url : https://faas-blr1-8177d592.doserverless.co/api/v1/web/fn-c2f6a867-3589-4d9d-be04-a587c0224939/api/prod/getUser

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

Let's just summarize:

  • You created a deploy.zip with the dist and node_modules folders.
  • Replaced deploy.zip inside packages/api/prod with the zip file you created.
  • So you ran 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?

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

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
}

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

Yes, your deploy.zip is working but I don't see any packages missing in my
deploy (2).zip

But has some extra packages

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

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

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

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.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

Sure, I will remove it manually as of now, also can this be also fixed #2 (comment)
node-modules-packer was missing out modules which had folder names starting with @ on my PC

Thanks for the help,

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

Hey @jmd9019, I release a new version of @h4ad/node-modules-packer, try running again with it to see if now works.

from serverless-adapter-examples.

jmd9019 avatar jmd9019 commented on June 19, 2024

Hi @H4ad,
I tried "@h4ad/node-modules-packer": "^1.2.1" on windows now it's deploying correctly.
Thanks for the help.

from serverless-adapter-examples.

H4ad avatar H4ad commented on June 19, 2024

Nice man, thanks for using it and reporting this bug.

from serverless-adapter-examples.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.