Hey! I'm trying to do `sst start` on a monorepo wi...
# help
c
Hey! I'm trying to do
sst start
on a monorepo with the sample ts api example but getting an error. The debugger starts just fine, but as soon as I make an api request it fails.
The endpoint do work without running the debugger
have anyone seen a similar error?
j
Hmm that’s weird. Can you post your node and npm versions?
c
Sure! node:
12.13.0
npm:
6.12.0
j
Thanks. This seems like a Windows specific issue. We haven't tested this a ton on there. But we do have other Windows users. Can you also post the version of Windows? We'll try and setup and environment to test this.
c
Got it. I'm on Windows 10 Home
j
Yeah we'll try and setup an environment and to replicate this.
c
Thanks Jay! Let me know if I can help
j
Yeah actually you could help us debug a bit. Give us one sec to figure out the exact steps.
f
Hi @Camilo Rios, from the screenshot you sent, it seems the debugger actually received the Lambda request
GET /
but failed when it tried to spawn a process to run your local code.
If you head over to the file in the stack trace
C:\Users\camil\Desktop\Temis\temis-core\services\rest-api\node_modules\@serverless-stack\cli\scripts\start.js
and around line 971, you should see
const lambda = spawn(..
That's trying to spawn a
bootstrap.js
file which will import your lambda handler
./src/lambda.handler
c
No problem! I will get to this first thing tomorrow morning. I'm also having another issue when trying to build locally
f
And then around line 1097, you should see
lambda.on("exit", function() {..
which gets called after the spawned process exits.
It seems the
spawn
failed with the error
EBADF: bad file descriptor, uv_pipe_open
and the
exit
callback was invoked right away.
Let me take a look at this build issue.
c
I will check if this is related to the monorepo. I will recreate the service outside the monorepo and try again
f
Yup, let me know.
c
Nope, same problem, so its more likely its a windows thing
f
Has
sst build
worked on your local before?
j
Hey @Camilo Rios, Have you considered using the Windows Subsystem for Linux? (https://docs.microsoft.com/en-us/windows/wsl/install-win10) Maybe that could help solving the problem.
c
@Frank yes, when I have a service without lambda functions it work (e.g creating a dynamodb table). But it doesn't work when the service has lambda functions. I started using the tool a couple of days ago, so haven't had much time to test different scenarios
@John Nguyen thanks! That's a great option, but it will be good if we can make it work for windows users OOTB.
f
@Camilo Rios I was not able to reproduce either the
sst build
and
sst start
issue on a windows 10 machine (launch via AWS WorkSpaces).
Here is my setup:
Copy code
node v12.13.0
npm v6.12.0
PowerShell 5.1.14393.3866
I ran
winver
in PS and it says "Windows Server 2016 Datacenter".
What did I try:
Copy code
npx create-serverless-stack@latest my-sst-app
cd my-sst-app
npx sst build
npx sst start
I was trying to compare the terminal output I got vs ur screenshot for
sst build
, I noticed the extra slash in your handler
Here's what I see in the my PowerShell output:
Can you try out the steps I tried above and see if you run into issues?
Copy code
npx create-serverless-stack@latest my-sst-app
cd my-sst-app
npx sst build
npx sst start
c
Thanks Frank, I will try that. The weird thing is that when building through Seed everything seems to work just fine
So the problem is related to the
defaultFunctionProps
. If I use the
srcPath
it fails, but if I just define the full path in the routes it works. (I was following the example here https://docs.serverless-stack.com/constructs/Api#specifying-function-props-for-all-the-routes)
Still having the issue when doing
yarn start
though
This works:
Copy code
npx create-serverless-stack@latest my-sst-app
cd my-sst-app
npx sst build
npx sst start
Going to try the Typescript example (which is the one that I'm using)
Yep, also worked, might be something in my monorepo config
f
Just to clarify, both
build
and
start
commands work for you when you tried the starter project?
c
yep, both worked 👍
The issues I'm getting with the typescript monorepo are most likely related to a setting on my end
I will let you know if I manage to fix them
Although I still have this problem with the starter project https://serverless-stack.slack.com/archives/C01JG3B20RY/p1613389644159700
f
So there are two issues: 1.
build
command fails if you use a
srcPath
2.
start
command fails in your monorepo setup
Is that right?
c
yep, but on the monorepo + typescript
f
Got it.
Do you think you can share a stripped down version of your monorepo setup with the
sst start
issue? I can try to reproduce it on my windows setup.
c
of course, I can add you to the repo, there is nothing super secret there
f
That'd be awesome. My github email is wangfanjie@gmail.com
c
👍
done
f
Got it! It's the
rest-api
service that's having the issue right?
c
yep
f
What's ur
srcPath
and route handler set to when the
build
command fails for you?
i see
srcPath
is currently commented out
c
its set to
/src
f
and the route is
"GET /": "src/lambda.handler"
?
c
👍
@Frank So the
yarn start
issue only happens when trying it inside a monorepo. I tried different configurations (js and ts) but both throws the same error. I based the monorepo on this one https://github.com/AnomalyInnovations/serverless-lerna-yarn-starter but also other configurations, but with no luck. I haven't been able to pin point the problem, but I will let you know if I find something. Are you able to run it on your side inside a monorepo?
f
It's taking me a bit to setup my git credentials on windows.. really need to get used to windows 😁
c
jajaja
let me know if I can help! We really want to start using SST and Seed in our projects
f
Yup I will let you know as soon as I try it out.
Aight I managed to reproduce the
build
command issue.
This works:
srcPath: "src"
srcPath: "src/"
works on mac/linux, but fails on windows
we would need to handle path building better for windows
Let me take a look at the
start
command issue now.
Have you seen this issue before?
Copy code
===================
 Starting debugger
===================

Transpiling Lambda code...
Debug session started. Listening for requests...
Error: Failed to load plugin '@babel' declared in 'BaseConfig': Cannot find module '@babel/eslint-plugin'
Require stack:
- /Users/frank/Sites/fwang/temis-core/services/rest-api/__placeholder__.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.resolve (internal/modules/cjs/helpers.js:94:19)
    at Object.resolve (/Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js:28:50)
    at ConfigArrayFactory._loadPlugin (/Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/config-array-factory.js:1017:39)
    at /Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/config-array-factory.js:908:33
    at Array.reduce (<anonymous>)
    at ConfigArrayFactory._loadPlugins (/Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/config-array-factory.js:904:22)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/config-array-factory.js:725:44)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/frank/Sites/fwang/temis-core/node_modules/@eslint/eslintrc/lib/config-array-factory.js:665:20) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/frank/Sites/fwang/temis-core/services/rest-api/__placeholder__.js'
  ],
  messageTemplate: 'plugin-missing',
  messageData: {
    pluginName: '@babel/eslint-plugin',
    resolvePluginsRelativeTo: '/Users/frank/Sites/fwang/temis-core/services/rest-api',
    importerName: 'BaseConfig'
  }
}
c
yep, I also run into that issue
but adding the module seems to solve it
Here is a simpler implementation without the noise of TS and other packages. It gives the same
start
issue
f
Right. I actually moved the
rest-api
service out as a standalone repo, and removed TS.
And I still get the
EBADF: bad file descriptor
error
I'm cross checking the project structure against the clean sst project and trying to spot a different.
It seems to be an yarn issue on windows
Could you help me verify that this causes the same problem for you:
Copy code
npm init serverless-stack@latest my-sst-app --use-yarn
yarn start
@Camilo Rios I created a test release with the fix. Change
@serverless-stack/cli
and
@serverless-stack/resources
to version
0.9.3-next.1
in your package.json.
This should fix both the
build
issue when
srcPath
is specified; and the
EBADF: bad file descriptor
issue when running
yarn start
Let me know if it works for you, and I will cut an official release.
c
Awesome! Let me give it a try
@Frank its now working on a monorepo without Typescript (build and start issues), thanks!!! In the typescript monorepo its not able to find typescript, I will check if its something on my end
f
hmm on which step are you seeing the typescript error?
c
when trying to build
I did a fresh install but its still failing to find typescript
I will keep looking
f
Copy code
npm init serverless-stack@next my-sst-app --language typescript --use-yarn
yarn build
Could you try that and see if it works in a non-monorepo setup?
c
yep, one sec
yes, it worked in a non-monorepo setup. The problem with the monorepo setup is that its trying to look for the tsc bin in the service folder.
f
I see.. it’s happening to
rest-api
on
yarn build
?
c
rest-api
, but I removed the
node_modules
and
yarn.lock
and installed everything again and now its building
I'm trying
yarn start
now
also working! Thanks @Frank for all the help!!
f
removing
node_modules
and
yarn.lock
fixed the typescript issue in monorepo?
c
yep
I will keep testing to see if I can break it again and understand what's going on
f
Awesome! Glad it’s all working. I will go ahead and cut an official release.
c
Thanks!