You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement first query and import some external function into the query file:
import{typeGetFirstName}from"wasp/server/operations";import{capitalize}from"./capitalize";// <-------- Important external import! exportconstgetFirstName: GetFirstName<never,string>=()=>{returncapitalize("john");};
Implement second query and call first query from that
import{getFirstName,typeGetFullName}from"wasp/server/operations";exportconstgetFullName: GetFullName<never,string>=async()=>{constfirstName=awaitgetFirstName();// <-------- Calling first query!return`${firstName} Smith`;};
Call a query from client
const{ data }=useQuery(getFullName);
Observed behavior
Server crashes with the following error:
[ Server!] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/***/dev/wasp-bug-sample/.wasp/out/sdk/wasp/dist/ext-src/capitalize' imported from /Users/***/dev/wasp-bug-sample/.wasp/out/sdk/wasp/dist/ext-src/getFirstName.js
[ Server!] at finalizeResolution (node:internal/modules/esm/resolve:257:11)
[ Server!] at moduleResolve (node:internal/modules/esm/resolve:913:10)
[ Server!] at defaultResolve (node:internal/modules/esm/resolve:1037:11)
[ Server!] at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:650:12)
[ Server!] at #cachedDefaultResolve (node:internal/modules/esm/loader:599:25)
[ Server!] at ModuleLoader.resolve (node:internal/modules/esm/loader:582:38)
[ Server!] at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:241:38)
[ Server!] at ModuleJob._link (node:internal/modules/esm/module_job:132:49) {
[ Server!] code: 'ERR_MODULE_NOT_FOUND',
[ Server!] url: 'file:///Users/***/dev/wasp-bug-sample/.wasp/out/sdk/wasp/dist/ext-src/capitalize'
Removing external import (i.e. removing import { capitalize } from "./capitalize"; and inlining capitalize function) fixes the issue.
Environment
Apple Sillicon
Node.js v22.11.0
Wasp 15.0
Additional context
It is possible to "work around" the issue by commenting out problematic line, thefore causing build error, and then uncommenting the line again. I would speculate that there's a race condition during build time and external module (capitalize) is being built later than query (getFirstName)
The text was updated successfully, but these errors were encountered:
Describe the bug
On a server, calling a query from another query throws an error
Error [ERR_MODULE_NOT_FOUND]: Cannot find module ...
.To Reproduce
Sample repo
Observed behavior
Server crashes with the following error:
Removing external import (i.e. removing
import { capitalize } from "./capitalize";
and inliningcapitalize
function) fixes the issue.Environment
Additional context
It is possible to "work around" the issue by commenting out problematic line, thefore causing build error, and then uncommenting the line again. I would speculate that there's a race condition during build time and external module (
capitalize
) is being built later than query (getFirstName
)The text was updated successfully, but these errors were encountered: