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

Local function execution is unable to load handler #1695

Closed
Rediate15 opened this issue Jul 5, 2023 · 7 comments
Closed

Local function execution is unable to load handler #1695

Rediate15 opened this issue Jul 5, 2023 · 7 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Rediate15
Copy link

Description
When I try to run a function locally with the command kyma run function the newly created container throws the following error: user code load error: Error: Cannot find module './function/handler'. It appears the container isn't able to load the handler.

Kyma-CLI: 2.15.0
Docker: 24.0.2
Windows 10

Expected result
The function is run in a local container and accessible through a given port.

Actual result
A new container is started, however, while trying to load the handler, the container throws an error:

- Ran container: function-funny-karol5
  Container listening on port: 8080
Logs from the container:
npm WARN config production Use `--omit=dev` instead.

up to date, audited 139 packages in 929ms

20 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
npm notice
npm notice New minor version of npm available! 9.5.0 -> 9.7.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.7.2>
npm notice Run `npm install -g npm@9.7.2` to update!
npm notice
user code load error: Error: Cannot find module './function/handler'
Require stack:
- /usr/src/app/server.js
Content loaded is not a function Error: Cannot find module './function/handler'
Require stack:
- /usr/src/app/server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Hook._require.Module.require (/usr/src/app/node_modules/require-in-the-middle/index.js:81:25)
    at require (node:internal/modules/cjs/helpers:110:18)
    at loadFunction (/usr/src/app/server.js:43:15)
    at Object.<anonymous> (/usr/src/app/server.js:159:12)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/src/app/server.js' ]
}

The container itself continues running

Steps to reproduce

  1. kyma init function
  2. kyma run function
  3. Open http://localhost:8080 in your browser

Note: These are the steps I need to reproduce. A colleague wasn't able to reproduce following the same steps

Troubleshooting
I've tried adding a reference to the config by adding sourceHandlerName: handler.js, but to no avail.
Switching to the node16 runtime results in the same error, however the deprecated node14 runtime only throws an error after accessing http://localhost:8080.
The following error is thrown by the node14 runtime:

- Ran container: function-funny-karol5
  Container listening on port: 8080
Logs from the container:
npm WARN saveError ENOENT: no such file or directory, open '/kubeless/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/kubeless/package.json'
npm WARN kubeless No description
npm WARN kubeless No repository field.
npm WARN kubeless No README data
npm WARN kubeless No license field.

up to date in 0.628s
found 0 vulnerabilities

Function failed to execute: internal/modules/cjs/loader.js:934
  throw err;
  ^

Error: Cannot find module '/kubeless/handler.js'
Require stack:
- /kubeless_rt/kubeless.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:931:15)
    at Module.Hook._require.Module.require (/kubeless_rt/node_modules/require-in-the-middle/index.js:81:25)
    at require (internal/modules/cjs/helpers.js:107:18)
    at modRequire (/kubeless_rt/kubeless.js:79:16)
    at require (/kubeless_rt/kubeless.js:153:29)
    at /kubeless/handler.js:2:21
    at Script.runInContext (vm.js:144:12)
    at Script.runInNewContext (vm.js:149:17)
    at /kubeless_rt/kubeless.js:158:24
    at AsyncLocalStorage.run (async_hooks.js:314:14)
Function failed to execute: internal/modules/cjs/loader.js:934
  throw err;
  ^

Error: Cannot find module '/kubeless/handler.js'
Require stack:
- /kubeless_rt/kubeless.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:931:15)
    at Module.Hook._require.Module.require (/kubeless_rt/node_modules/require-in-the-middle/index.js:81:25)
    at require (internal/modules/cjs/helpers.js:107:18)
    at modRequire (/kubeless_rt/kubeless.js:79:16)
    at require (/kubeless_rt/kubeless.js:153:29)
    at /kubeless/handler.js:2:21
    at Script.runInContext (vm.js:144:12)
    at Script.runInNewContext (vm.js:149:17)
    at /kubeless_rt/kubeless.js:158:24
    at AsyncLocalStorage.run (async_hooks.js:314:14)

@pPrecel pPrecel added the kind/bug Categorizes issue or PR as related to a bug. label Jul 6, 2023
@pPrecel
Copy link
Contributor

pPrecel commented Jul 6, 2023

Hello @Rediate15, thank you for creating such a detailed ticket. Definitely, it's a bug. For now, I can't find any hotfix for this problem. I moved it to our team and we will try to find some time and look at it.

@pPrecel
Copy link
Contributor

pPrecel commented Jul 6, 2023

The issue does not occur on macOS systems (on my Macbook it's working really fine), probably the problem is reproducible only on Windows systems only

@kyma-bot
Copy link

kyma-bot commented Sep 9, 2023

This issue or PR has been automatically marked as stale due to the lack of recent activity.
Thank you for your contributions.

This bot triages issues and PRs according to the following rules:

  • After 60d of inactivity, lifecycle/stale is applied
  • After 7d of inactivity since lifecycle/stale was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Close this issue or PR with /close

If you think that I work incorrectly, kindly raise an issue with the problem.

/lifecycle stale

@kyma-bot kyma-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 9, 2023
@kwiatekus kwiatekus removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 14, 2023
@kyma-bot
Copy link

This issue or PR has been automatically marked as stale due to the lack of recent activity.
Thank you for your contributions.

This bot triages issues and PRs according to the following rules:

  • After 60d of inactivity, lifecycle/stale is applied
  • After 7d of inactivity since lifecycle/stale was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Close this issue or PR with /close

If you think that I work incorrectly, kindly raise an issue with the problem.

/lifecycle stale

@kyma-bot kyma-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 13, 2023
@kwiatekus kwiatekus removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 14, 2023
@kyma-bot
Copy link

This issue or PR has been automatically marked as stale due to the lack of recent activity.
Thank you for your contributions.

This bot triages issues and PRs according to the following rules:

  • After 60d of inactivity, lifecycle/stale is applied
  • After 7d of inactivity since lifecycle/stale was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Close this issue or PR with /close

If you think that I work incorrectly, kindly raise an issue with the problem.

/lifecycle stale

@kyma-bot kyma-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 13, 2024
@janmedrek janmedrek removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 15, 2024
@janmedrek
Copy link
Contributor

@pPrecel @kwiatekus are there any plans to move this forward? Or should we close it with the wontfix label?

@janmedrek
Copy link
Contributor

Stopping the development according to: kyma-project/community#872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

6 participants