How do I enable console.log?
console.logs, console.infos don't seem to show up in the log in the dashboard, nor when using
npx convex dev --tail-logs
, am I missing something 🙂 ?22 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
Are the logs inside of a convex function?
Logs always print, nothing to enable.
Maybe you're looking at the wrong deployment in the dashboard?
Not showing in local dev either
@bear where are these console.logs, inside of a function that you're running? [edit: oops erquhart already asked this]
yep, normal console.log inside the handler
and I do see my requests coming in
What kind of function is it? Could you paste the code for one?
Are you using any npm libraries that might be monkeypatching or shadowing console?
no it's very barebones
What if you
npx convex run yourfilename:create '{"data": 1}'
random, but any chance this has an effect?
I get these on startup and every call, note that the "task" does get created
Ah!
Convex mutations are transactions, if one part doesn't go through then none of it does
I don't think your deploys are taking then
really
my tasks are created though
If schema validation fails, you can't push
On the dashboard of this deployment in the functions tab, what is the code there?
OH
wait so I have to fix my data to push?
or change your schema so that it matches your data
you're trying to move from one schema to another schema, and the new one doesn't apply
I see
so you'll need to do a migration, or (probably easier for a small project) just change the data to match the new schema
makes sense, thank you
often a two-step proceess, e.g. addinga new field requires making the field optional in the schema, pushing that, then changing the data, then pushing the schema where it's required
yeah you can't push your functions separately from your schema, they're always a package deal
you can turn off schema enforcement if you want, that's a convenient way to iterate and then clean up later
https://docs.convex.dev/database/schemas#schemavalidation-boolean
perfect 🙂
just beware that if you do that your TypeScript types may not be accurate, TypeScript won't know that some of the items in that table don't actually have that field
(probably obvious, just making clear for anybody following along)
I'll make my fields optional for now, thanks again