epicweb-dev / web-auth

Take ownership of you application's authentication and authorization
https://www.epicweb.dev
Other
288 stars 84 forks source link

Error Loading Lessons in Playground #9

Closed L-Steinmacher closed 1 year ago

L-Steinmacher commented 1 year ago

I experienced a few errors in the app when loading a lesson from Mock GitHub OAuth into the playground.

Stack Error

[exercises__sep__17.oauth__sep__02.problem.flow:6162] 
[playground:4000] GET / 200 - - 53.276 ms
[playground:4000] 
[playground:4000] 9:58:50 AM [tsx] restarting
[playground:4000] 
[playground:4000] Debugger listening on ws://127.0.0.1:9229/129abb8c-b96e-4c13-896e-3248d9eab2ac
[playground:4000] For help, see: https://nodejs.org/en/docs/inspector
[playground:4000] 
[playground:4000]  info  rebuilding... (~ app/routes/_auth+/login.tsx)
[playground:4000]  info  rebuilding... (~ app/routes/_auth+/auth.github.ts)
[playground:4000]  info  rebuilding... (~ app/routes/_auth+/auth.github.callback.ts)
[playground:4000] 
[playground:4000] 🔶 Mock server installed
[playground:4000]  info  rebuilt (834ms)
[playground:4000] 
[playground:4000] Error: Cannot find module '/Users/Panzermensch/Desktop/Projects/web-auth/playground/build/index.js' imported from /Users/Panzermensch/Desktop/Projects/web-auth/playground/server/index.ts
[playground:4000] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/Panzermensch/Desktop/Projects/web-auth/playground/build/index.js' imported from /Users/Panzermensch/Desktop/Projects/web-auth/playground/server/index.ts
[playground:4000]     at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
[playground:4000]     at new NodeError (node:internal/errors:405:5)
[playground:4000]     at finalizeResolution (node:internal/modules/esm/resolve:226:11)
[playground:4000]     at moduleResolve (node:internal/modules/esm/resolve:838:10)
[playground:4000]     at defaultResolve (node:internal/modules/esm/resolve:1036:11)
[playground:4000]     at nextResolve (node:internal/modules/esm/hooks:733:28)
[playground:4000]     at E (file:///Users/Panzermensch/Desktop/Projects/web-auth/node_modules/tsx/dist/loaders-deprecated-261ba186.mjs:12:49)
[playground:4000]     at D (file:///Users/Panzermensch/Desktop/Projects/web-auth/node_modules/tsx/dist/loaders-deprecated-261ba186.mjs:12:1279)
[playground:4000]     at async nextResolve (node:internal/modules/esm/hooks:733:22)
[playground:4000]     at async Hooks.resolve (node:internal/modules/esm/hooks:242:24)
[playground:4000]     at async MessagePort.handleMessage (node:internal/modules/esm/worker:168:18)
[playground:4000
kentcdodds commented 1 year ago

Thanks! I'm pretty sure if you stop and start the app again it'll work. This probably has to do with the build output from remix not being ready when the server is ready. This is weird and something I should work on finding a fix for (I have ideas), but there's a workaround until I get to it.

L-Steinmacher commented 1 year ago

Yes! Restarting the app does work! Thank you!

L-Steinmacher commented 1 year ago

I can't tell if the original post error and this one are related but I did get this error and was not able to reproduce it. It did resolve itself after restarting the app is the only reason that I feel they may be related.

lesson: http://localhost:5639/21/03/problem Browser: Chrome

[playground:4000] 
[playground:4000] SyntaxError: The requested module '@prisma/client' does not provide an export named 'PrismaClient'
[playground:4000] /Users/Panzermensch/Desktop/Projects/web-auth/playground/app/utils/db.server.ts:2
[playground:4000] import { PrismaClient } from '@prisma/client'
[playground:4000]          ^
[playground:4000] 
[playground:4000] SyntaxError: The requested module '@prisma/client' does not provide an export named 'PrismaClient'
[playground:4000]     at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
[playground:4000]     at async ModuleJob.run (node:internal/modules/esm/module_job:188:5)
[playground:4000]     at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:228:24)
[playground:4000]     at FSWatcher.reloadBuild (/Users/Panzermensch/Desktop/Projects/web-auth/playground/server/index.ts:172:14)
[playground:4000] 
kentcdodds commented 1 year ago

Looks like setting to playground didn't work in that case. Clicking the link icon again will re-set it to the playground and that should fix it.

image

I should definitely document these workarounds somewhere (in addition to making it more resilient to issues like this).