Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Post requests dones't work locally #66

Open
Mostafa-wael opened this issue Aug 14, 2024 · 3 comments
Open

Bug: Post requests dones't work locally #66

Mostafa-wael opened this issue Aug 14, 2024 · 3 comments

Comments

@Mostafa-wael
Copy link

Mostafa-wael commented Aug 14, 2024

Description

Post requests don't work when using FaaS locally.

Details

After deploying the string manipulation example locally.

I ran curl http://localhost:9000/2604c2a8a4e4/examples-testing/v1/call/longest_repetition -X POST --data 'aaa' But it stuck and didn't return anything.

image

I found that the FaaS container shows this error when the function is called:

metacall_faas  | Server is running on the port 9000
metacall_faas  | examples-testing         | NodeJS Loader Error: NodeJS Loader could not convert the value of type 'Invalid' to N-API
metacall_faas  | examples-testing         | NodeJS Loader Error: NodeJS Loader could not convert the value of type 'Invalid' to N-API
metacall_faas  | examples-testing         | /metacall/dist/worker/index.js:82
metacall_faas  | examples-testing         |                         result: functions[fn.name](...fn.args)
metacall_faas  | examples-testing         |                                                   ^
metacall_faas  | examples-testing         | 
metacall_faas  | examples-testing         | Error: NodeJS Loader could not convert the value of type 'Invalid' to N-API
metacall_faas  | examples-testing         |     at process.<anonymous> (/metacall/dist/worker/index.js:82:51)
metacall_faas  | examples-testing         |     at process.emit (node:events:517:28)
metacall_faas  | examples-testing         |     at process.emit (node:domain:489:12)
metacall_faas  | examples-testing         |     at emit (node:internal/child_process:944:14)
metacall_faas  | examples-testing         |     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
metacall_faas  | examples-testing         | 
metacall_faas  | examples-testing         | Node.js v18.19.0

image

This is the output of the metacall-deploy --inspect OpenAPIv3 --dev command:

[
  {
    "openapi": "3.0.0",
    "info": {
      "title": "MetaCall Cloud FaaS deployment 'examples-testing'",
      "description": "",
      "version": "v1"
    },
    "servers": [
      {
        "url": "http://localhost:9000/2604c2a8a4e4/examples-testing/v1",
        "description": "MetaCall Cloud FaaS"
      }
    ],
    "paths": {
      "/call/longest_repetition": {
        "post": {
          "summary": "",
          "description": "",
          "requestBody": {
            "description": "",
            "required": true,
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "str": {}
                  }
                }
              }
            }
          },
          "responses": {
            "200": {
              "description": "",
              "content": {
                "application/json": {
                  "schema": {}
                }
              }
            }
          }
        }
      }
    }
  }
]

image

Obviously, when I send the request again the container crashes:

image

image

@viferga
Copy link
Member

viferga commented Aug 14, 2024

Yes, this bug is related to this: metacall/core#518

@viferga
Copy link
Member

viferga commented Aug 14, 2024

This can be solved after implementing metacallfms. This is available in version 0.8.1.
This should also solve this: #64

@viferga
Copy link
Member

viferga commented Aug 14, 2024

@HeeManSu once the linux distributable CI finishes, you can try to implement this.

In the worker, you will need to change the metacall_load_from_configuration_export to metacall_load_from_configuration, and then use call by name with metacallfms.

You have an example of the API here:
metacall/core@649a054

Check the test, it's calling a function by passing the name of the function and the json as string directly. This will solve the problems related to the call.

The body parser for json can be removed and we can use plain text for the call and await with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants