https://pulumi.com logo
#typescript
Title
# typescript
f

freezing-electrician-6256

11/22/2023, 10:05 PM
I have noticed that when I have typescript errors in my code, i get this error when trying to run pulumi:
Copy code
Cannot convert object to primitive value
and nothing in the stack trace indicates towards where the error is (syntax or otherwise). has anyone else experienced this, and is there any way to see what the actual typescript error is? i am using
eglot
in emacs for typescript LSP integration, and it doesnt show any errors right now, but at least in the past when I got this error I wasn't running the language server and was unknowingly introducing errors. full stack trace is like this, but it's not very helpful:
Copy code
error: Running program '/home/user/infrastructure/project-pulumi' failed with an unhandled exception:
    TypeError: Cannot convert object to primitive value
        at process.uncaughtHandler (/home/user/infrastructure/project-pulumi/node_modules/@pulumi/cmd/run/run.ts:266:66)
        at process.emit (node:events:526:35)
        at process.emit (/home/user/infrastructure/project-pulumi/node_modules/source-map-support/source-map-support.js:516:21)
        at emit (node:internal/process/promises:150:20)
        at processPromiseRejections (node:internal/process/promises:284:27)
        at processTicksAndRejections (node:internal/process/task_queues:96:32)
ah i figured out my issue currently, my repos were in a weird state (was on the wrong branch for a component resources repo). but still, this keeps happening to me and i haven't figured out how to debug it
hm. i guess i can just run
tsc
lol. somehow i'm not used to actually running it, when i've used ts in the past it's usually baked into e.g. a bundler or my editor
welp, i fixed the error that
tsc
reported and I am still getting the same error message 😭
just kidding i'm getting a different error that actually points back to my code, so maybe i'm getting somewhere...
l

little-cartoon-10569

11/23/2023, 1:16 AM
What is project-pulumi? If it's your repository, why (how?) are you running it directly? Is this an automation-api program, or a vanilla Pulumi project?
f

freezing-electrician-6256

11/23/2023, 1:16 AM
its a placeholder for the name of my pulumi project directory. i am running it directly at the moment
i managed to resolve that latter issue by deleting node_modules and re-running npm install in my component resources project
i think something about running
tsc
messed with my project 😞
probably want to run it with some option that doesnt emit any files
l

little-cartoon-10569

11/23/2023, 1:18 AM
It seems odd that your Pulumi CLI is wrapping a call that's throwing an exception that's being caught by run.ts. That's got to be a bit hint (to the Pulumi devs who know that code.. I know I don't know that code!).
f

freezing-electrician-6256

11/23/2023, 1:19 AM
that's a good call... maybe that could be a place to find things
also wonder if it has to do with ts-node
l

little-cartoon-10569

11/23/2023, 1:20 AM
It might, since by default, Pulumi's wrapper uses ts-node to call your Pulumi project. Have you got anything strange in the runtime config in your Pulumi.yaml?
f

freezing-electrician-6256

11/23/2023, 1:21 AM
Copy code
runtime:
  name: nodejs
  options: 
    # See <https://github.com/TypeStrong/ts-node/issues/1007>
    nodeargs: "--loader ts-node/esm --no-warnings --experimental-specifier-resolution=node"
this is not a project i started, so i dont know for sure why those specific args are there
l

little-cartoon-10569

11/23/2023, 1:23 AM
Those are required for ESM. If you're not using it, you can remove them. If you are using them and you remove them, then you will enter a World of Pain.
f

freezing-electrician-6256

11/23/2023, 1:23 AM
i am using ESM, and i think i was in that world of pain earlier haha
l

little-cartoon-10569

11/23/2023, 1:24 AM
I've never seen a #-comment right there though... would you like to try removing it briefly to see if that changes anything? It probably won't, but no harm, eh?
3 Views