Issue with deploying my wasp app to fly.io

I'm trying to deploy my wasp app to fly.io, but I'm encountering an error that doesn't make sense. When I run wasp start and operate on my localhost, everything works perfectly, but when I run "wasp deploy fly deploy" it goes through an bunch of steps and ends on this error:
"../../../src/client/admin/components/Header.tsx(1,31): error TS2307: Cannot find module 'wasp/auth/types' or its corresponding type declarations.\n"
}
"../../../src/client/admin/components/Header.tsx(1,31): error TS2307: Cannot find module 'wasp/auth/types' or its corresponding type declarations.\n"
}
Saying that it can't find the path to wasp/auth/types even though this wasn't an issue for the localhost. Can anyone help me with this?
15 Replies
miho
mihoβ€’2mo ago
Can you please check that you are running at least Wasp 0.12.4? We had a bug fix related to that import: https://github.com/wasp-lang/wasp/releases/tag/v0.12.4 Run wasp version to check your Wasp version. Upgrade to 0.12.4 by running: curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.12.4 Optional If you want to upgrade to 0.13.0 at some point, here are the docs for that as well: https://wasp-lang.dev/docs/migrate-from-0-12-to-0-13
rithvik12345678
rithvik12345678β€’2mo ago
Yeah I'm on 0.12.3, so I'll update and try again Also @miho Is there a way to see the exact code that fly deploys? I upgraded and it successfully deployed, but some of the functionality on my localhost is missing on my deployed website.
MEE6
MEE6β€’2mo ago
Wohooo @rithvik12345678, you just became a Waspeteer level 2!
miho
mihoβ€’2mo ago
Wasp generates all the code it deploys to .wasp/build folder πŸ˜„ you can inspect there the web-app folder and the server folders. This is your app πŸ™‚ It's just Node.js + React What is missing for you? Maybe you didn't setup some env variables?
rithvik12345678
rithvik12345678β€’2mo ago
It's the login and signup buttons that are missing
miho
mihoβ€’2mo ago
DM me your project link if you don't want to share it here πŸ˜„ So @rithvik12345678 needs to modify the server code a bit to execute some code after login / after signup. We have a hooks feature planned (https://github.com/wasp-lang/wasp/issues/1556) but it's not available, yet 😦 So the problem we are facing is: how to modify the outputed code from Wasp to get this custom behaviour. In dev it's a matter of modifying the .wasp/out files. When deploying to Fly, Wasp builds a fresh build in .wasp/build so those manual changes won't be deployed. Here's an idea that might work for you: 1. One of the maybe best way to solve this is to have a "patched" versioned of the file you need to modify, somewhere in the project root. 2. Then you provide your own custom Dockerfile (which can be just the copy paste version of the Dockerfile in .wasp/build folder) 3. In that Dockerfile include a line with something like cp ./my-patched-file.js server/something/somewhere.js It's quite a bit advanced option, here's some details in the docs: https://wasp-lang.dev/docs/advanced/deployment/overview#customizing-the-dockerfile Basically, copy-paste the whole Dockerfile to your project root and Wasp will use that file to build your server container instead of the default file. In your Dockerfile, you now can add the extra cp command that will copy over the patched file to the built app before deploying it. (I'd suggest doing this at line number 42 just above the npm run bundle line) Huh, this is pretty hard-core, I have to say! We should really prioritise the hooks feature. @martinsos
rithvik12345678
rithvik12345678β€’2mo ago
Oh interesting @miho , so are you saying that I can modify the dockerfile in wasp/out to have a command that copies the modified wasp code from wasp/out into wasp/build and it'll use that to generate the website?
miho
mihoβ€’2mo ago
If you have a Dockerfile in the project root (the same folder where main.wasp lives) Wasp will use it when building your server πŸ™‚
rithvik12345678
rithvik12345678β€’2mo ago
Oh, really? That's pretty convenient @miho I've bee trying to do what you said. So I moved my modified files to the root directory, I pushed these changes to my github repo, and added these lines to the dockerfile in my root dir: COPY ./waspchangedcode/createRouter.ts .wasp/build/server/src/auth/providers/oauth/createRouter.ts COPY ./waspchangedcode/signup.ts .wasp/build/server/src/auth/providers/email/signup.ts COPY ./waspchangedcode/verifyEmail.ts .wasp/build/server/src/auth/providers/email/verifyEmail.ts preceding this line: RUN cd .wasp/build/server && npm run bundle However everytime I run wasp deploy fly deploy I get this error:
'#17 [server-builder 13/14] COPY ./waspchangedcode/verifyEmail.ts .wasp/build/server/src/auth/providers/email/verifyEmail.ts\n' +
'#17 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/verifyEmail.ts": not found\n' +
'\n' +
'#18 [server-builder 11/14] COPY ./waspchangedcode/createRouter.ts .wasp/build/server/src/auth/providers/oauth/createRouter.ts\n' +
'#18 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/createRouter.ts": not found\n' +
'\n' +
'#19 [server-builder 12/14] COPY ./waspchangedcode/signup.ts .wasp/build/server/src/auth/providers/email/signup.ts\n' +
'#19 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/signup.ts": not found\n' +
'------\n' +
'#17 [server-builder 13/14] COPY ./waspchangedcode/verifyEmail.ts .wasp/build/server/src/auth/providers/email/verifyEmail.ts\n' +
'#17 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/verifyEmail.ts": not found\n' +
'\n' +
'#18 [server-builder 11/14] COPY ./waspchangedcode/createRouter.ts .wasp/build/server/src/auth/providers/oauth/createRouter.ts\n' +
'#18 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/createRouter.ts": not found\n' +
'\n' +
'#19 [server-builder 12/14] COPY ./waspchangedcode/signup.ts .wasp/build/server/src/auth/providers/email/signup.ts\n' +
'#19 ERROR: failed to calculate checksum of ref a9e51645-2607-414a-99bb-1b44bc09a1f9::q2o2ntkq1xkg0xj5u95ofj25b: "/waspchangedcode/signup.ts": not found\n' +
'------\n' +
Saying that the file is not found. waspchangedcode is the folder that contains my modified code. I've tried a bunch of things and nothings been able to fix this error. Do you know what's happening?
miho
mihoβ€’2mo ago
How does your folder structure look? I'm asking where is your waspchangedcode relative to the project root and .wasp dir?
rithvik12345678
rithvik12345678β€’2mo ago
The waspchangedcode is in the app dir and .wasp is also in the app dir .wasp and waschangedcode are on the same level
miho
mihoβ€’2mo ago
Nice, okay that helps πŸ™‚ let me try to see how I would do it and then report back Okay, I got it to work. Here are the steps that I took πŸƒβ€β™‚οΈ My "patch" is just modifying the server's app.js file to add some dummy /test route. I kept my patch files in the src/patches folder. I'll explain why I had to do that below. 1. I ran wasp build to get some output in .wasp/build folder 2. I copied Dockerfile from .wasp/build to my project root 3. I added this line at line 37:
COPY ./src/patches/app.js .wasp/build/server/src/app.js
COPY ./src/patches/app.js .wasp/build/server/src/app.js
4. Then I ran wasp build to build it again Now let's test to see if the Dockerfile works πŸ§‘β€πŸ­ 1. cd .wasp/build and then docker build . -t customcode-test 2. Then I run the server with docker run -p 3001:3001 customcode-test to see if my custom code is there (/test route should work). 3. I visit http://localhost:3001/test and I see it works. Cool, let's see what else you need to know: 1️⃣ The missing info for you is: we build the Docker container from the .wasp/build folder - which makes that folder the "docker build context". You can only work with stuff that are in the context and if I put the "patches" dir at the project root - it won't work. Because the Wasp compiler won't copy that folder, it copies only the stuff it needs. So... what do we do? 2️⃣ You need to keep your "patches" folder in the "src" dir because it will get copied to the .wasp/build folder since Wasp needs the src folder. 3️⃣ I'd advise putting // @ts-ignore on top of the patch files to avoid getting weird TS compiler errors in dev and when it builds the code.
rithvik12345678
rithvik12345678β€’2mo ago
Ok @miho I tried it this way and it all runs successfully and deploys the site, but the actual code I'm trying to change at server/src/auth/providers/ is not actually changing. Once the build is over that code is exactly the same as the default code even though the copying ran successfully.
miho
mihoβ€’2mo ago
Make sure you are copying to the correct path πŸ˜„ that happened to me while I was trying to get it to work
martinsos
martinsosβ€’2mo ago
Yeah I agree regarding the prioritiziation! Also, having general hooks, that run whatever you give them before/after code generation, would also be helpful in situations like this, when more specific hooks are missing, as a super-general escape hatch. We also have a GH issue for this.