#TypeError: Can only call URLSearchParams.toJSON on instances of URLSearchParams

1 messages ยท Page 1 of 1 (latest)

desert citrus
#

Hi everyone,

I just created a function to build my mini monorepo using Dagger. This function is supposed to replace the entire build command in the Dockerfile. I'm calling it with the command: dagger call build-backend --service-name=user --source .., but I'm receiving an error like the one in the title. You can find my Dagger Cloud link here: https://dagger.cloud/duclee/traces/bec99e298723b1ff84bf579acebcb1d4.

Any insights for debugging would be appreciated!

the current dagger function files:
`@object()
export class Pipelines {
@func()
installPackage(source: Directory): Container {
return dag
.container()
.from("oven/bun:1.2.11-alpine")
.withWorkdir("/app")
.withMountedCache("./node_modules", dag.cacheVolume("monorepo_node_modules"))
.withDirectory(".", source, {include: ["package.json","./**/*/package.json"]})
.withExec(["bun","install","--frozen-lockfile"])
}

@func()
buildBackend(serviceName: string, source: Directory): Container {
const serviceList = Object.keys(ServiceName);
if (!serviceList.includes(serviceName)) {
throw new Error(Service name '${serviceName}' is not recognized. Available services: ${Object.keys(ServiceName).join(", ")});
}
const packages = this.installPackage(source); // cache the result!
return dag
.container()
.from("oven/bun:1.2.11-alpine")
.withWorkdir("/app")
.terminal()
.withDirectory("./node_modules", packages.directory("/app/node_modules"))
.withFile("./package.json", packages.file("./package.json"))
.withDirectory(./src/${serviceName+"-service"}, source.directory(./src/${serviceName+"-service"}))
.withEnvVariable("DATABASE_URL", "file:./dev.db")
.withExec(["bun","prisma:generate"])
.withExec(["bun","run","build"])
.terminal()
}
}
`

delicate spoke
# desert citrus Hi everyone, I just created a function to build my mini monorepo using Dagger....

hey Duc!

Apparently the error seems to be misleading and related to https://github.com/dagger/dagger/issues/10406.

Focusing on the actual issue, I can see from your trace the error attached in the image.

You can't really select directories that are part of cache volumes (withMountedCache) since those are not actually part of the DAG. So your buildBackend function is failing here: .withDirectory("./node_modules", packages.directory("/app/node_modules")).

what you can do instead of the above, is to mount the same cache volume in the over/bun:1.2.11-alpine container you create in the buildBackend function to the location that you need. So basically calling withMountedCache("./node_modules", npmCache).

LMK if that makes sense ๐Ÿ™

delicate spoke