Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working with goa #2

Merged
merged 9 commits into from
Oct 31, 2023
Merged

Working with goa #2

merged 9 commits into from
Oct 31, 2023

Conversation

akm
Copy link
Owner

@akm akm commented Oct 24, 2023

No description provided.

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

At 9865cde , App shows the error on browser.

スクリーンショット 2023-10-25 7 36 02
$ npm run dev

> todo-with-sveltekit-and-goa@0.0.1 dev
> vite dev



  VITE v4.5.0  ready in 533 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help
7:35:06 [vite] Error when evaluating SSR module /goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js:
|- ReferenceError: require is not defined
    at $HOME/sandbox/todo_with_sveltekit_and_goa/goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js:12:12
    at instantiateModule (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)

7:35:06 [vite] Error when evaluating SSR module /src/lib/apisvr/client.ts: failed to import "/goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js"
|- ReferenceError: require is not defined
    at $HOME/sandbox/todo_with_sveltekit_and_goa/goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js:12:12
    at instantiateModule (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)

7:35:06 [vite] Error when evaluating SSR module /src/routes/+page.server.ts: failed to import "/src/lib/apisvr/client.ts"
|- ReferenceError: require is not defined
    at $HOME/sandbox/todo_with_sveltekit_and_goa/goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js:12:12
    at instantiateModule (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:56052:15)

ReferenceError: require is not defined
    at $HOME/sandbox/todo_with_sveltekit_and_goa/goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js:12:12
    at instantiateModule (file://$HOME/sandbox/t

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

This error looks like the same error in sveltejs/kit#655 .
It can be fixed by sveltejs/kit#759 ?

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

At each commit 4f96443 and d9393ab, App shows the same error as #2 (comment)

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

At commit f96978f , App shows the same error as #2 (comment) .

@akm
Copy link
Owner Author

akm commented Oct 24, 2023

Now studying vite....

$ npx vite build

vite v4.5.0 building SSR bundle for production...
✓ 80 modules transformed.
✓ built in 290ms
"TodosClient" is not exported by "goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js", imported by "src/lib/apisvr/client.ts".
file: $HOME/sandbox/todo_with_sveltekit_and_goa/src/lib/apisvr/client.ts:4:9
2: import { credentials } from '@grpc/grpc-js';
3: 
4: import { TodosClient, type ITodosClient } from '../../protos/goagen_goa_todo_example_todos_grpc_pb';
            ^
5: import {
6:   ListRequest,
error during build:
RollupError: "TodosClient" is not exported by "goa_todo_example/clients/nodejs/src/protos/goagen_goa_todo_example_todos_grpc_pb.js", imported by "src/lib/apisvr/client.ts".
    at error (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at Module.error (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
    at Module.traceVariable (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:14175:29)
    at ModuleScope.findVariable (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:12615:39)
    at Identifier.bind (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:8319:40)
    at NewExpression.bind (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
    at VariableDeclarator.bind (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
    at VariableDeclaration.bind (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
    at Program.bind (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)
    at Module.bindReferences (file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/rollup/dist/es/shared/node-entry.js:13741:18)

@akm
Copy link
Owner Author

akm commented Oct 28, 2023

アプローチを変更するので、ここまでの試みは https://github.com/akm/todo_with_sveltekit_and_goa/releases/tag/harkens%2Ftry_to_use_sveltejs_adapter-node で残すとして、一旦リセット。

@akm akm force-pushed the features/working_with_goa branch from f96978f to ae20425 Compare October 28, 2023 11:56
@akm
Copy link
Owner Author

akm commented Oct 29, 2023

Error

Client-side code calls Server-side code with HTTP API, but gRPC client fails to call gRPC APIs. gRPC server doesn't get any request from gRPC client in SvelteKit app.

buid was OK
$ npm run build

> todo-with-sveltekit-and-goa@0.0.1 build
> vite build


vite v4.5.0 building SSR bundle for production...
✓ 104 modules transformed.

vite v4.5.0 building for production...
✓ 77 modules transformed.
.svelte-kit/output/client/_app/version.json                              0.03 kB │ gzip:  0.05 kB
.svelte-kit/output/client/_app/immutable/assets/remove.74788b08.svg      0.42 kB │ gzip:  0.25 kB
.svelte-kit/output/client/.vite/manifest.json                            2.56 kB │ gzip:  0.48 kB
.svelte-kit/output/client/_app/immutable/assets/2.d95034d9.css           0.41 kB │ gzip:  0.26 kB
.svelte-kit/output/client/_app/immutable/nodes/0.10888380.js             0.60 kB │ gzip:  0.38 kB
.svelte-kit/output/client/_app/immutable/nodes/1.0b9ee786.js             1.03 kB │ gzip:  0.59 kB
.svelte-kit/output/client/_app/immutable/chunks/singletons.f99258cd.js   2.85 kB │ gzip:  1.46 kB
.svelte-kit/output/client/_app/immutable/nodes/2.dd47c802.js             3.87 kB │ gzip:  1.90 kB
.svelte-kit/output/client/_app/immutable/chunks/index.3f2f7f2b.js        5.54 kB │ gzip:  2.34 kB
.svelte-kit/output/client/_app/immutable/entry/app.be85d096.js           5.85 kB │ gzip:  2.32 kB
.svelte-kit/output/client/_app/immutable/entry/start.c6d15161.js        24.89 kB │ gzip:  9.80 kB
.svelte-kit/output/client/_app/immutable/chunks/scheduler.95fed9fc.js   32.04 kB │ gzip: 10.10 kB
✓ built in 361ms
.svelte-kit/output/server/_app/immutable/assets/remove.74788b08.svg   0.42 kB
.svelte-kit/output/server/.vite/manifest.json                         2.64 kB
.svelte-kit/output/server/_app/immutable/assets/_page.a9cb30b2.css    0.43 kB
.svelte-kit/output/server/internal.js                                 0.19 kB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js          0.27 kB
.svelte-kit/output/server/entries/endpoints/todo/_server.ts.js        0.53 kB
.svelte-kit/output/server/entries/endpoints/todo/_id_/_server.ts.js   0.67 kB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js           0.92 kB
.svelte-kit/output/server/entries/pages/_page.server.ts.js            0.99 kB
.svelte-kit/output/server/entries/pages/_page.svelte.js               1.40 kB
.svelte-kit/output/server/chunks/index.js                             1.99 kB
.svelte-kit/output/server/chunks/ssr.js                               3.72 kB
.svelte-kit/output/server/chunks/index2.js                            4.21 kB
.svelte-kit/output/server/chunks/internal.js                         10.18 kB
.svelte-kit/output/server/chunks/grpc_client.js                      78.06 kB
.svelte-kit/output/server/index.js                                   88.33 kB

Run npm run preview to preview your production build locally.

> Using @sveltejs/adapter-auto
  Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing
  ✔ done
✓ built in 1.84s
$ npm run preview

> todo-with-sveltekit-and-goa@0.0.1 preview
> vite preview


  ➜  Local:   http://localhost:4173/
  ➜  Network: use --host to expose
  ➜  press h to show help
Error: undefined undefined: undefined
    at callErrorFromStatus ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/call.js:31:19)
    at Object.onReceiveStatus ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/client.js:192:76)
    at Object.onReceiveStatus ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:360:141)
    at Object.onReceiveStatus ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at $HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/resolving-call.js:99:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
for call at
    at ServiceClientImpl.makeUnaryRequest ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/client.js:160:32)
    at ServiceClientImpl.create ($HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
    at ServiceClientImpl.<anonymous> (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/chunks/grpc_client.js:738:18)
    at createTodo (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/chunks/grpc_client.js:2435:68)
    at POST (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/entries/endpoints/todo/_server.ts.js:11:24)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async render_endpoint (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/index.js:223:20)
    at async resolve (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/index.js:2714:22)
    at async respond (file://$HOME/sandbox/todo_with_sveltekit_and_goa/.svelte-kit/output/server/index.js:2603:22)
    at async file://$HOME/sandbox/todo_with_sveltekit_and_goa/node_modules/@sveltejs/kit/src/exports/vite/preview/index.js:174:5 {
  code: undefined,
  details: undefined,
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

This problem seems to cause from somewhere between gRPC client and vite.
akm/goa_todo_example#5

@akm akm force-pushed the features/working_with_goa branch from ae20425 to ba01a76 Compare October 31, 2023 13:05
@akm
Copy link
Owner Author

akm commented Oct 31, 2023

Resolved !

a lot of try and error スクリーンショット 2023-10-31 22 10 29

@akm akm marked this pull request as ready for review October 31, 2023 13:09
@akm akm merged commit 824df39 into main Oct 31, 2023
@akm akm deleted the features/working_with_goa branch October 31, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant