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

serverless-patched with pnpm is broken #2492

Open
3 tasks done
matusfaro opened this issue Sep 21, 2022 · 1 comment
Open
3 tasks done

serverless-patched with pnpm is broken #2492

matusfaro opened this issue Sep 21, 2022 · 1 comment

Comments

@matusfaro
Copy link

Issue Summary

When using serverless-patched doesn't work with pnpm.

Actual behavior

Calling serverless-patched seems to work as the note is printed. but the Deploying logs are still present:

Note: running patched serverless binary.
...
81s › dataspray › Deploying 
81s › dataspray › Deploying .
81s › dataspray › Deploying .
81s › dataspray › Deploying ..

The findUpSync logic finds an unpatched serverless instance due to pnpm's node_modules structure.

Expected behavior

Deploying ... logs should not be printed

Steps to reproduce

pnpm with serverless-patched

Versions

  • OS/Environment: macos 12.2.1
  • @sls-next/serverless-patched: ^3.4.0

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
  • You have first tried using the most recent latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

Possible issues to address:

  1. Use the proper patched serverless binary
  2. Don't print Note: running patched serverless binary. inside bin/serverless-patched.ts but add this log line to the patch @serverless+cli+1.5.3.patch itself. It was very confusing to track down this issue because of this. Bonus: detect whether the patch is present.
  3. Upstream this to @serverless/cli

To be honest, the amount of work put into this workaround, it seems upstreaming is the best option unless they are hesitant to accept patches.

@matusfaro
Copy link
Author

matusfaro commented Sep 21, 2022

For others stumbling here with pnpm:

Don't use serverless-patched, use pnpm to apply the patch directly onto serverless like this:

package.json:

  "scripts": {
    "deploy": "SERVERLESS_CLI=true serverless --debug",
  },
  "devDependencies": {
    "serverless": "^2.72.2",
  },
  "pnpm": {
    "patchedDependencies": {
      "@serverless/cli@1.6.0": "patches/@serverless__cli@1.6.0.patch"
    }
  }

@serverless__cli@1.6.0.patch:

diff --git a/src/Context.js b/src/Context.js
index 4fb9da9b8a10ba8bc4ff82adab17e9605bf6d53e..ea13d974159fc17203d9dfa7dd5930a1dc29c9fb 100644
--- a/src/Context.js
+++ b/src/Context.js
@@ -153,7 +153,11 @@ class CLI {
     process.stdout.write(ansiEscapes.cursorShow)
     if (!this.isStatusEngineActive()) {
       console.log() // eslint-disable-line
-      process.exit(0)
+      if (reason === 'error') {
+        process.exit(1)
+      } else {
+        process.exit(0)
+      }
       return
     }
     return this.statusEngineStop(reason, message)
@@ -244,6 +248,10 @@ class CLI {
       this._.entity = entity
     }
 
+    if (!process.stdout.isTTY || !!process.env.SERVERLESS_CI) {
+      return;
+    }
+
     // Loading dots
     if (this._.status.loadingDotCount === 0) {
       this._.status.loadingDots = `.`

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

1 participant