Provide own default error page in Fresh
Hello! I'm seeing the following error
Can I provide my own default error page instead of this one to sidestep this error? I tried making such a page at
routes/default_error_page.tsx
, but that didn't work
Something that could be related, but that I'm confused about is that this refers to fresh@1.0.1
when my import_map.json
specifies fresh@1.1.4
Any ideas? Thanks in advance!39 Replies
The error means that in
deno.jsonc
you have set jsx runtime to automatic, but you also have set a pragma on the file. This was the way to do it on the early versions of fresh. Remove the following lines and you’ll be good to go.
Edit: You’re also probably looking for this https://fresh.deno.dev/docs/concepts/error-pagesPerfect, this is exactly what I was looking for. Thanks @jaboolo !
you're welcome! <:cookie_deno:1002977285734932480>
I'm trying to implement that, but I'm still confused — I added a page
routes/_404.tsx
that looks like this
Yet I'm still seeing that when pushing to heroku something appears to be implicitly requiring the default_error_page.tsx:1:1
Note that the fresh versions aren't aligned.
Do you know what might be going on @jaboolo ?
Is your repo public? If not, can you send me your
import_map.json
and deno.jsonc
files?It's private, here you are!
I don't have a deno.jsonc, here's my
deno.json
Are you sure you have deleted all
pragmas
? These are comments at the top of the files, such as
In my own source files yes, although something implicitly seems to be importing this file: https://deno.land/x/fresh@1.0.1/src/server/default_error_page.tsx?source=#L1
There you can see the pragma at the top
Yup, that's the second weird stuff, normally fresh
v1.0.1
shouldnt get importedYeah, I'm confused by that
Is there a way to trace what packages are importing what?
I'm going to check one thing, I can kinda imagine what's causing it
perfect, I appreciate you!
Does it work locally?
Like, is the problem happening when you push and it builds
it works locally, the problem appears to be on push & install
Alright
I've just checked https://github.com/chibat/heroku-buildpack-deno, do you have the
runtime.txt
file set to 1.32.4
(latest) or similar?oh!? I don't have one yet. Let me add one
trying that now...
Okay, when I set
1.32.4
that didn't work, but v1.32.4
got further, so it's clearly recognizing the runtime.txt
file. That said, I'm seeing the same error
Alright, I see. Just a quick question, have you tried deno deploy?
I haven't yet — I have an existing set of configs (redis, postgres) in Heroku and so I'm seeing about porting the project there for now
Understood. I recommend trying deploy, it doesn't depend on 3rd packages to bundle stuff, so it just works, and really good if you ask me
other than that I cant think of anything else for your issue
Appreciate the advice. Going back to a prior question — is there a way to trace the dependency tree to see what might be importing fresh@1.0.1 ?
The issue is happening on the build step for heroku. One thing you can do, if theres a way to hook a script is to run
deno vendor
, and grep fresh@1.0.1
to see whats importing it
Nonetheless this is really hackyThanks for this — perhaps if I also include a lock file that might help
indeed, that's a good one
let me know if using a lock works
I was previously seeing issues with that, but perhaps now with the deno version set to be my local version that might have been the cause of issues
I'll try that
That's super weird at this point
let me check what that gh module's doing
I appreciate your checking
Have you tried using the module locally? https://github.com/chibat/heroku-deno-getting-started#running-locally
If it doesnt work, then its that module messing up with the imports
nvm thats not what I thought it did
Ah yeah, that just seems to try the sample project
not actually run the build locally
Yeah
Imma just deploy a project i have and debug hahah
hahaha, nice one!
Definitely let me know if you want to pair on that or want any other notes/assistance from me. I also have view-related stuff I can work on, just to say I'm sure you have other responsibilities and so just know I'm not blocked immediately by this.
For what it's worth — I'm able to reproduce the issue locally without having anything to do with Heroku like so
Okay so then it’s not heroku related, that’s great. Is the fresh project newly created? If not give this a shot: https://fresh.deno.dev/docs/concepts/updating
Updating Fresh | fresh docs
Fresh regularly releases new versions of the framework. This page explains how to update your project.
Thanks for passing this along @jaboolo . I tried using that step to update the packages, but unfortunately am still seeing the exact same error (few packages were changed and only minor version #'s as the project is quite new)
Okay, the problem is definitely with fresh-session as you can see the import statements here: https://github.com/xstevenyung/fresh-session/blob/main/src/deps.ts
GitHub
fresh-session/deps.ts at main · xstevenyung/fresh-session
Dead simple cookie-based session for Deno Fresh. Contribute to xstevenyung/fresh-session development by creating an account on GitHub.
No worries, I was puzzled too but in the end it makes sense, an old package. You should choose another module <:cookie_deno:1002977285734932480>
For sure, thanks for all your help along the way. Is there a better package for session management in fresh? I was looking around the docs and nothing seemed obvious.
In the meanwhile I'm just pointing to a forked version of that repo with dependencies updated
I cant think of it, but the package seems to pass the state in the context and access that from all routes, shouldnt be that hard to implement
Makes sense — thanks again!
Youre welcome! Good luck