a year ago
Seems that something changed in the Railway infra because even 'redeploying' previously working projects, I'm getting this new error during build. Any idea why redeploys suddenly error on mime types?
``WARN config production Use
--omit=dev` instead.
12 0.802
12 0.802 > medusa-starter-default@0.0.1 clean
12 0.802 > cross-env ./node_modules/.bin/rimraf dist
12 0.802
12 1.738 production environment using .env.production
12 35.94 error TS2688: Cannot find type definition file for 'mime'.
12 35.94 The file is in the program because:
12 35.94 Entry point for implicit type library 'mime'
12 ERROR: process "/bin/bash -ol pipefail -c cross-env npm run clean && cross-env medusa-admin build && tsc -p tsconfig.server.json" did not complete successfully: exit code: 2
[stage-0 8/10] RUN --mount=type=cache,id=s/fb3a601a-4fe9-4358-8ffd-12d303256e6e-nodemodules/cache,target=/app/nodemodules/.cache cross-env npm run clean && cross-env medusa-admin build && tsc -p tsconfig.server.json:
WARN config production Use--omit=dev
instead.
0.802
0.802 > medusa-starter-default@0.0.1 clean
0.802 > cross-env ./node_modules/.bin/rimraf dist
0.802
1.738 production environment using .env.production
35.94 error TS2688: Cannot find type definition file for 'mime'.
35.94 The file is in the program because:
35.94 Entry point for implicit type library 'mime'
Dockerfile:24
22 | # build phase
23 | COPY . /app/.
24 | >>> RUN --mount=type=cache,id=s/fb3a601a-4fe9-4358-8ffd-12d303256e6e-nodemodules/cache,target=/app/nodemodules/.cache cross-env npm run clean && cross-env medusa-admin build && tsc -p tsconfig.server.json
25 |
26 |
ERROR: failed to solve: process "/bin/bash -ol pipefail -c cross-env npm run clean && cross-env medusa-admin build && tsc -p tsconfig.server.json" did not complete successfully: exit code: 2
Error: Docker build failed
```
2158ac66-80be-42ae-b4e4-d6bbbe244d21
0 Replies
To be clear, this suddenly started happening on multiple of my projects, that have had no changes, and deployed properly as recently as yesterday. Simply clicking 'redeploy' is enough to get the error to happen. So I've changed nothing and this new error is popping up. Very confused.
Railway projects suddenly failing with new "Cannot find type definition file for 'mime'" Error
a year ago
are you commiting your node_modules folder to github?
I'm guessing something happened with Railway's nixpacks version, that has resulted in a brand new error on previously working code.
And as a result multiple projects that worked in a previous infra are now all crashing down. Shame.
a year ago
have you tried looking for solutions to this error? it wouldnt be isolated to railway
I'm even trying to 'redeploy' instances that were previously working and they also crash with this new error.
a year ago
redeploy will redeploy, you might want a rollback instead
a year ago
while i agree with you when you say that a nixpacks version bump introduced something different, this would not be an error that you could only get on railway
a year ago
saying that its railway infra related is not a correct sentence
I'm not deeply familiar with nixpacks, but basically multiple versions, multiple branches, multiple databases, ALL now fail on a redeploy or new deploy. Why would old (previously working) projects all suddenly fail in the same way.
Perhaps it's more correct to say the way railway deploys nixpacks is the issue? I may be wrong to even be looking at nixpacks, hence asking for help.
a year ago
databases dont use nixpacks, lets keep the scope of this to your service please
a year ago
have you tried looking for solutions to this error?
Just trying to get across that it's a sudden issue across a whole bunch of different applications with different setups, applications versions etc, which to me points to infra (railway, nixpacks, something else, not sure), but I have no idea which part of the infra to look at.
The 'error' is in a library my program made no change or has no specific reference to. And yes I've searched for solutions to it, but have found nothing useful.
a year ago
what is the nixpacks version of the last working deployment?
I'm not sure how to find that, or even control it. As I'm only using nixpacks as it was recommended for railway. I'm not even sure I understand the concept of a 'nixpacks version'.
a year ago
look at the build table in the build logs
The most recent successful build was over 30 days ago, so I cannot see build logs. Any other way to see it? And on Railway is there even a way to force an older version of nixpacks, or is that inaccessible?
For reference, my nixpacks.toml looks like this:
```[phases.setup]
nixPkgs = ['nodejs', 'yarn', 'postgresql_16']
[phases.install]
cmds=['yarn install']```
Perhaps the nodejs version got bumped too far and has created this Typescript error in my projects? If so, I could perhaps lock the nodejs version (if that's even possible).
a year ago
respectfully, with a nixpacks.toml like that im suprised it has ever worked
a year ago
do you use yarn or npm locally?
a year ago
do you have a yarn lock file?
a year ago
do you have an npm lock file?
a year ago
do you use yarn v1?
is your yarn lock file in sync with your package.json?
Yeah, I keep yarn lock in sync with package.json with yarn install, and committing it all together.
a year ago
nope, the opposite actually
a year ago
why do you need postgresql_16
?
a year ago
or.. do you need it?
Because I use postgresql_16 in a script in my application that backs up my database to S3.
Since the DB on Railway are now postgres16, I needed that running on the server.
a year ago
indeed
a year ago
replace your nixpacks.toml with this
[phases.setup]
nixPkgs = ['...', 'postgresql_16']
Status changed to Solved railway[bot] ⢠about 1 year ago
Note that I originally got that nixpacks recommended format from here (https://docs.medusajs.com/deployments/server/deploying-on-railway), my project is a Medusa app.
a year ago
i know
a year ago
but i dont know why they would add that
Heh, fair enough. For interest, does that mean Railway will pick what to install? (nixpacks dummy, remember)..
a year ago
nixpacks will detect this is a node app that uses yarn and install and run the applicable stuff
Ok, so do I also remove this from my nixpacks.toml?[phases.install] cmds=['yarn install']
a year ago
yes
Thank you, rebuilding and the nixpacks header shows this now:
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā Nixpacks v1.21.2 āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā setup ā nodejs_18, yarn-1_x, postgresql_16 ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā install ā yarn install --check-cache ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā build ā cross-env npm run clean && cross-env medusa-admin build && tsc ā ā ā -p tsconfig.server.json ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā start ā medusa migrations run && medusa start ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
a year ago
looks better
a year ago
it does
a year ago
set engines.node
to 20
a year ago
it would be done on your local project and you push the changes to github
a year ago
does create-medusa-app
use yarn or npm by default? yarn
Ooof, not sure, that was almost a year ago I ran that. I think medusa gave you the option, I seem to remember manually removing the npm stuff.
a year ago
looks like its yarn lock file only
Ok, that package.json worked to force it to node 20 instead of 18. Learning! (thank you btw, was scouring the internet for hours with no luck, this help is far more directed).
a year ago
that would be outlined here
a year ago
use yarn v1 locally and sync your lock file again
Is there a reason to be moving backwards with yarn? Is it because railway doesn't properly support yarn v2?
a year ago
railway uses yarn v1
Ok, wondering if that will create issues with medusa, which I believe uses yarn v2.
a year ago
they use v1
a year ago
so delete your lock file and then yarn install
to make a new one with v1
Doing that added this to my package.json, do I want the version to be added that specifically?
"packageManager": "yarn@1.22.19"
And it also added yarnPath: .yarn/releases/yarn-1.22.19.cjs
to my .yarnrc.yml
fileā¦
a year ago
dont do any of that please
a year ago
railway uses yarn v1 already, all you need to do is use yarn v1 locally and have a v1 lock file in your project
I think when I rolled back to yarn v1 with yarn set version classic
it added those two linesā¦so I will remove them.
a year ago
Okay, so that's all re-built, still getting that mime error, any further ideas from the railway side to investigate and figure out when this error actually creeped in? That is, back to the original issue of old deploys working on the same codebase where new deploys are now failing.
a year ago
now it comes down to some issue with your project / deps
a year ago
what solutions have you tried to fix this?
Well that's where I'm confused, it deployed fully fine a couple months ago, it's just when I redeploy (same code, config, etc) where it starts to fail. The language around that error appears to be a typescript thing, so I'm guessing the typescript version changed in what gets deployed on railway in the past couple months (I had stepped away from the project for a bit). And so my next deploy after that gap in time just now fails. Is there any way to force Railway to deploy with nixpacks versions from a month ago? Or am I thinking about this incorrectly?
I wanted to add in the type definitions for mime
as a test, but as far as I can tell, it's typed right inside the library. So there's nothing to add. I added the latest mime-types anyways, but that didn't work.
Interestingly, this is what I get from yarn why mime
- I have nothing about mime in my package.json
though.
āā @types/mime@npm:4.0.0 ā āā mime@npm:4.0.1 (via npm:*) ā āā send@npm:0.18.0 āā mime@npm:1.6.0 (via npm:1.6.0)
a year ago
please can we take the blame away from railway, i understand how it looks but this is not an issue with the platform
Not blaming, just trying to see that it may be something to do with infra (more likely that I haven't controlled something and it's simply manifesting with an infra change)
a year ago
Is there any way to force Railway to deploy with nixpacks versions from a month ago?
yesOr am I thinking about this incorrectly?
yes
a year ago
pinning this on railway is only going to cloud your judgment
It's more that if I can find an old infra it works on, I can step forward and may be able to discover the source of the issue or better debug. But in parallel I'm also trying to figure out the bug with this 'mime' library and typing.
Arg, somehow yarn has 're-updated' itself to v3.5.0. Not sure how that happened.
a year ago
thats not ideal
Looks like the moment I removed this line from the .yarnrc.yml it reverted to the v3.5.0
a year ago
remove yarn v3 from your computer
Ok, ran this command corepack prepare yarn@1.22.19 --activate
and that worked, will reinstall and redeploy now with yarn v1 (as apparently I never did)
So this is very weird⦠I ran yarn why mime
:
```~/sites/medusa-app/backend$ yarn why mime
yarn why v1.22.19
[1/4] Why do we have the module "mime"�
[2/4] Initialising dependency graphā¦
[3/4] Finding dependencyā¦
[4/4] Calculating file sizesā¦
=> Found "mime@1.6.0"
info Reasons this module exists
"express#send" depends on it
Hoisted from "express#send#mime"
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "76KB"
info Disk size with transitive dependencies: "76KB"
info Number of shared dependencies: 0
=> Found "@types/mime#mime@4.0.1"
info This module exists because "@types#express#@types#serve-static#@types#mime" depends on it.
info Disk size without dependencies: "168KB"
info Disk size with unique dependencies: "168KB"
info Disk size with transitive dependencies: "168KB"
info Number of shared dependencies: 0```
And then checking express, it's the latest version:
~/sites/medusa-app/backend$ yarn list express yarn list v1.22.19 warning Filtering by arguments is deprecated. Please use the pattern option instead. āā @medusajs/admin@7.1.12 ā āā express@4.18.2 āā express@4.19.2
So what doesn't make sense is how latest version of express seems to be using a very OLD version of mime (1.6.0) but a very NEW version of its types (4.0.1).
My package.json sets express as "express": "^4.17.2",
So, PERHAPS the bug is in expressā¦digging in deeper but does this at all make sense to you?
a year ago
have you deleted your node_modules folder and then ran all the same commands railway does to install deps, build and run your project right?
I did a yarn cache clean
, but you're right, should have nuked node_modules for a fresh start.
a year ago
and then ran all the same commands railway does to install deps, build and run your project right?
Innnnteresting. Getting the same local error now on yarn build. Only since getting properly on yarn v1. This should help debug without having to deploy!
More interesting, I just used medusa-create-app
to make a fresh medusa install, and the response to yarn why mime
is different⦠NO idea why this would be with my package.json, which refers to the SAME versions of expressā¦
```=> Found "mime@1.6.0"
info Reasons this module exists
"express#send" depends on it
Hoisted from "express#send#mime"
info Disk size without dependencies: "76KB"
info Disk size with unique dependencies: "76KB"
info Disk size with transitive dependencies: "76KB"
info Number of shared dependencies: 0```
a year ago
very odd
a year ago
the joys of node dependencies
Yep, using this to dig further⦠thank you for your help to date. Recognise this is no longer (that is, never was) a 'railway' thing but nevertheless has been extremely useful.
So damn weirdā¦
This is what the express and send versions are in the FRESH install:
~/sites/medusa-new-test$ yarn list express warning Filtering by arguments is deprecated. Please use the pattern option instead. āā @medusajs/admin@7.1.12 ā āā express@4.18.2 āā express@4.19.2 ~/sites/medusa-new-test$ yarn list send warning Filtering by arguments is deprecated. Please use the pattern option instead. āā send@0.18.0
And in my install, after removeing the node_modules folder and the yarn.lock file:~/sites/medusa-app/backend$ yarn list express warning Filtering by arguments is deprecated. Please use the pattern option instead. āā @medusajs/admin@7.1.12 ā āā express@4.18.2 āā express@4.19.2 ~/sites/medusa-app/backend$ yarn list send warning Filtering by arguments is deprecated. Please use the pattern option instead. āā send@0.18.0
Banging head on wall at this point. Same package.json, same actual versions, but somehow this mime v4 in my project seems to be screwing everything up:=> Found "@types/mime#mime@4.0.1" info This module exists because "@types#express#@types#serve-static#@types#mime" depends on it.
Going deeper with yarn why @types/mime
:
My project:
```~/sites/medusa-app/backend$ yarn why @types/mime
yarn why v1.22.19
[1/4] Why do we have the module "@types/mime"�
[2/4] Initialising dependency graphā¦
[3/4] Finding dependencyā¦
[4/4] Calculating file sizesā¦
=> Found "@types/mime@4.0.0"
info Reasons this module exists
"@types#express#@types#serve-static" depends on it
Hoisted from "@types#express#@types#serve-static#@types#mime"
info Disk size without dependencies: "196KB"
info Disk size with unique dependencies: "272KB"
info Disk size with transitive dependencies: "272KB"
info Number of shared dependencies: 1
=> Found "@types/send#@types/mime@1.3.5"
info This module exists because "@types#express#@types#express-serve-static-core#@types#send" depends on it.
info Disk size without dependencies: "24KB"
info Disk size with unique dependencies: "24KB"
info Disk size with transitive dependencies: "24KB"
info Number of shared dependencies: 0
And the new test project:
~/sites/medusa-new-test$ yarn why @types/mime
yarn why v1.22.19
[1/4] Why do we have the module "@types/mime"�
[2/4] Initialising dependency graphā¦
[3/4] Finding dependencyā¦
[4/4] Calculating file sizesā¦
=> Found "@types/mime@1.3.5"
info Reasons this module exists
"@types#express#@types#serve-static" depends on it
Hoisted from "@types#express#@types#serve-static#@types#mime"
Hoisted from "@types#express#@types#express-serve-static-core#@types#send#@types#mime"
info Disk size without dependencies: "24KB"
info Disk size with unique dependencies: "24KB"
info Disk size with transitive dependencies: "24KB"
info Number of shared dependencies: 0```
a year ago
welp time to start over with a new medusa project
Hah, no way⦠There must be some way to rectify this. My package.json isn't that much different from default. Is there anything to wipe aside from node_modules and the yarn cache that could be messing w this?
a year ago
i honestly wouldnt know
WOW! Adding this to my package.json got past that failing build step:
"resolutions": { "@types/mime": "1.3.5" }
Not a great fix, forcing a dependency like this, but at least helps dig deeperā¦
a year ago
thats node for you š
One last question, does this seem right in the nixpacks like this with --check-cache? Shouldn't I be wiping the cache in Railway?
āāāāāāāāāāāāāāāāā Nixpacks v1.21.2 āāāāāāāāāāāāāāāā ā setup ā nodejs_20, yarn-1_x, postgresql_16 ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā install ā yarn install --check-cache ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā build ā yarn run build ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā start ā yarn run start ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
a year ago
that is odd
a year ago
its doing that because you have a yarnrc.yml file
This is what's in my yarnrc.yml file, is this needed or should i nuke that file?
nodeLinker: node-modules
a year ago
yeah get rid of it
Great, so several wins:
I undersand nixpacks better and have a healthier use of it on Railway
You've nicely updated Medusa's documentation to avoid future mishaps like mine
I "sorta" understand that I have a node dependencies issue and have a short-term hack around it.
Wins and beers around!!
a year ago
and at this point your build has gone out and you are back up?
note nixpacks looks like this now:
ā install ā yarn install --frozen-lockfile ā
a year ago
thats what id expect it to be
a year ago
what other issues are in the way?
Well now there seems to be an issue with medusa-admin not properly building before I can fully get to my prior state (says that date-fns package isn't available even though it's in the lockfile). I expect I'll get there though, and at that point, Medusa's routes suddenly stopped being registered for some of my medusa plugins and therefore the server application failed to start. Everything I've been blocked on today was simply to try to upgrade Medusa to the latest version to see if I just happened to catch a bug that only manifest in my project at that version. Have done all the necessary database migrations, etc.
All of this is very strange, as again there was no change to my codebase, environment variables, anything (hence my looking at infrastructure). All seems to be quite the tangle. Frustrating as it was all just chugging away working fine from code back before Christmas until last month and then just suddenly started falling apart. Natural return of order to chaos I suppose.
Hmmm, have just figured out one more 'Railway config' thing I don't understand. I had my nicely working from before Railway instance hooked up to github, and THAT one is failing during build, however I just made a 'fresh' one and it's working. Pointing at the same github branch though. Is there any history / memory / cache at all the Railway github instances hold onto between code deploys? Not sure why the build step would fail on one and succeed on another otherwise..
a year ago
railway does do build caching on a per service bases
(it's been a service for a while so perhaps it's an old 'version' of the service too, it's been up since the fall)
a year ago
NIXPACKS_NO_CACHE=1
a year ago
in the service variables
Nice. Trying that to see if I can bring my service back to life. If that doesn't work, I'll just use the 'new' one I just made (that works) and then configure it to use SSL (through DNS) etc. to match my 'old' one then retire it. Not my fave method but it'll work.
a year ago
configure it with SSH (through DNS) etc
huh?
Yep it worked! So that dependency thing in my admin build must have been from a cache issue. Is there a good reason to actually keep caches on in Railway? Seems unfortunate if they can mess w dependencies in this way.
Basically, I meant using the Networking to set a custom domain, and using DNS to get it to work (with SSL). Sorry spoke unclearly.
a year ago
Is there a good reason to actually keep caches on in Railway?
it would normally speed up builds
a year ago
whats ssh have to do with railway?
It's not directly, it's more that I use Railway to set redirects to https:// then then I have to set up that domain DNS to the proper Railway server, AND get the SSL (https) certificate. All just tasks that come off of the change in Railway.
a year ago
odd because railway doesnt offer ssh
Awwww, shoot, everytime I said SSH up there I actually meant SSL, and now I understand your confusionā¦Oops! Edited my messages for clarity.
a year ago
haha quite confused
Just talking about this really⦠and how it requires DNS configuration (completely ourside and not related to Railway) in order to function properly.
a year ago
btw you can move your domain over to a new railway service without touching any dns stuff
a year ago
but i assume you already did all that, so this is info for a next time
Even better, I got the original one working (by nuking the cache through that service variable) so didn't need to migrate at all.
a year ago
oh perfect
Hah, get this absolute node craziness. Just on a whim, I decided to remove the resolution for mime
now that it was all working, and guess what? It works both locally and on Railway. Makes no sense at all, but perhaps it 'kicked' it out of a weird dependency funk by just getting it to work onceā¦
I mean it does sort of make sense as there's really no logical reason it should have been versioning mime
in that inconsistent wayā¦
a year ago
this is indeed node magic
Further magic. Have switched back to the default NIXPACKS_NO_CACHE=false
and lo-and-behold it all still works⦠Seems this was a 'spider-web-clearing' exerciseā¦
Ok, full circle and in summary, I now have ALL environments [local, test (on railway), staging (on railway) and prod (on railway)] restored and properly running through a combination of:
upgrading medusa
cleaning up the nixpacks as per your suggestions
clearing the nixpacks cache in Railway with the
NIXPACKS_NO_CACHE
service variabledoing necessary database migrations (unrelated to this issue, but had to be done)
Of interest, to fix prod I did the least amount of manual stuff. That environment never saw the 'resolution' used to fix the 'mime' issue, I simply upgraded from November codebase to now. Then it presented the 'mime' issue, so I added the NIXPACKS_NO_CACHE
, redeployed and the issue went away and everything deployed perfectly. So that's of interest for anyone presented with a similar future issue, try a pass of that (you can turn it back to default afterwards) for these weird issues presenting on Railway (or any deployment environment) when using Nixpacks. At this point, I'm actually unsure I needed to upgrade Medusa at all, perhaps the nixpacks cache fix on the old codebase would have been enough, but I can't know at this point as I fixed too fast.
a year ago
I'm pretty sure NIXPACKS_NO_CACHE=false
still disables cache, I don't think nixpacks checks if that value is a Boolean, I think it only checks if the value is set to anything and if it's set to anything it disables build caching
a year ago
and I know that at the very least it doesn't clear cache, it just won't use cache for the builds it set on