serverless / serverless

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.
https://serverless.com
MIT License
46.42k stars 5.71k forks source link

Compose fails to package explicit artifacts #12824

Closed danielvijge closed 1 week ago

danielvijge commented 3 weeks ago

Issue description

When using compose on services that have explicit artifact packages, the command fails with ✖ Error: Error: ENOENT: no such file or directory, open 'index.js' encountered during hash calculation for provided filePath: index.js

Steps to reproduce:

  1. Create two services, named service-a and service-b. I used the starter templates for both. Only add package.artifact to each service. Both services are the same, except for the service name.
    
    service: service-a
    frameworkVersion: '4'

provider: name: aws runtime: nodejs18.x

functions: function1: handler: index.handler package: artifact: index.js

3. Create a compose file for both services.
```yaml
services:
  service-a:
    path: service-a
  service-b:
    path: service-b
  1. Try to run a compose command, e.g. serverless package. This fails with the message ✖ Error: Error: ENOENT: no such file or directory, open 'index.js' encountered during hash calculation for provided filePath: index.js

Note if the files really do no exist at all, e.g. by renaming handler.js files, there is a different error message: ✖ Cannot access package artifact at "index.js" (for "function1"): ENOENT: no such file or directory, access '/code/service-b/index.js'

Going into a service folder and trying to package a service individually (cd service-a; serverless package)

Context

Serverless ϟ Support

This generates a report from your last Serverless Framework command (including any errors) to use for Github Issues, debugging w/ AI, or creating a support ticket w/ Serverless Inc.

Summary Report -----------------

Service Overview

Service Config

services:
  service-a:
    path: service-a
  service-b:
    path: service-b

Service Overview

Error Message

Error: Error: ENOENT: no such file or directory, open 'index.js' encountered during hash calculation for provided filePath: index.js

Error Stacktrace

at ReadStream.<anonymous> (file:///root/.serverless/releases/4.4.0/package/dist/sf-core.js:735:41032)
at ReadStream.emit (node:events:519:28)
at ReadStream.emit (node:domain:488:12)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Service Config

service: service-a
frameworkVersion: '4'
provider:
  name: aws
  runtime: nodejs18.x
functions:
  function1:
    handler: index.handler
    package:
      artifact: index.js

Service Overview

Error Message

Error: Error: ENOENT: no such file or directory, open 'index.js' encountered during hash calculation for provided filePath: index.js

Error Stacktrace

at ReadStream.<anonymous> (file:///root/.serverless/releases/4.4.0/package/dist/sf-core.js:735:41032)
at ReadStream.emit (node:events:519:28)
at ReadStream.emit (node:domain:488:12)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Service Config

service: service-b
frameworkVersion: '4'
provider:
  name: aws
  runtime: nodejs18.x
functions:
  function1:
    handler: index.handler
    package:
      artifact: index.js

Service Overview

Above is a summary report of your last Serverless Framework command.

Use it to debug with AI (e.g. ChatGPT) or report a new Github Issue: https://slss.io/issue

czubocha commented 1 week ago

Hey @danielvijge, thanks for reporting this. We’ve identified the issue and will be releasing a fix soon.

czubocha commented 1 week ago

@danielvijge the fix has been shipped in v4.4.5