Hey everyone, After upgrading to 0.69.5 i've lost ...
# help
s
Hey everyone, After upgrading to 0.69.5 i've lost the ability to automatically rebuild code after saved changes during 'sst start' mode (only stacks rebuilds, but not lambda code). Is there now some additional config to enable this?
l
@Stan you sure you've called the function at least once after running
sst start
? Otherwise it won't be built at all
Has to do with the functions being lazily initialized for a while now
s
yep, thats how i noticed the problem - lambda returned with the "old code". To make changes visible I need to stop the process and run "yarn start" again. If i remember correctly, before in terminal after saving some changes I got informations like "rebuilding infa and rebuilding code". Now I can only see "Stacks: Building changes... Stacks: Synthesizing changes..."
before I was at 0.46.1, so didn't heard yet about lazy loading. Thanks for the hint, I will double check that
ok, I've tested different options and it works like this - when i make some change inside lambda handler it will rebuild the changes in lambda and in imports. But when I change something in imports only, it will not rebuild at all. Is it possible to switch it off? Previous behaviour was way better, I can't imagine keeping all the code inside the lambda handler itself
l
Pretty sure that if you chat our local heroes, @thdxr, @Frank, they'll be able to work things out with ya
t
@Stan this sounds like a bug - in my setup this works the way you expect
Can you share with me your folder structure?
s
Hey thdxr, folder structure is a bit unusual at first, so I can describe more in detail where things are if needed. I started from your monorepo template with yarn workspaces published previous year on github
In src/microservices/aAPI i have a corresponding AApiStack.ts that contains API GW configuration. Endpoints are grouped by feature and for example user management lambdas are in src/microservices/aAPI/users/UsersLambdas.ts, endpoints definition is stored in UserEndpoints.ts and then imported to AApiStack.ts inside "routes" section of API GW. Implementation of lambdas is stored under src/packages, so in this case UsersService.ts will implement the logic and its under src/packages/a/user/UsersService.ts this service is imported by UsersLambdas.ts. When I make a change in UsersLambdas.ts, everything works ok, and I can see the changes made to both Lambdas.ts and Service.ts. When I make a change only in UsersService.ts, nothing gets rebuild (well, only infrastructure) and I need to run "sst start" again.
t
If they're two different packages how are importing between them?
Also where is your main file for the stacks?
s
index.ts is directly under src/
"src/packages/*" and "src/microservices/*" are yarn workspaces
t
This might be the issue, think we might be ignoring some of your code
we generally don't recommend mixing stacks code and application code in the same directory, even though they feel related
I'll see if I can track down this issue
s
so you would rather put all the stack related code in root/infra and app code in root/src ?
t
Yeah this repo is a bit outdated but it's roughly the pattern we encourage: https://github.com/serverless-stack/graphql-stack
stacks folder, and then a backend package with core for library code and functions for where things get mounted
somewhat similar to your setup
s
thanks, I will have a look on this one
Hey @thdxr! I've finally found some time to do refactoring of our app. I've moved the stacks to separate folder, simplified the project structure similar to graphql example and migrated to v1, but reloading the code still does not work properly for me. I've experimented a bit and I think the problem is when you import some function from the file that is not in the same directory path. As long as the file i'm importing from is in the same directory as lambda it works ok. But if I import from the file on different path it does not reload the new content on save.
I will try to prepare some small project that will reproduce this behaviour over the weekend