jason
jason2mo ago

Show full output of t3env

This might be hard to improve, but if the convex dev command were able to show the rest of T3 env's output, it'd make troubleshooting missing env vars easier, b/c the terminal only gives this level of detail (whereas T3's log output includes the names of the missing env variables):
✖ Error fetching POST https://foo-bar-123.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze auth.js: Uncaught Error: Invalid environment variables
at <anonymous> (../../node_modules/@t3-oss/env-core/dist/src-Bb3GbGAa.js:55:56)
at createEnv (../../node_modules/@t3-oss/env-core/dist/src-Bb3GbGAa.js:59:24)
at <anonymous> (../../src/env.ts:23:2)
✖ Error fetching POST https://foo-bar-123.convex.cloud/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze auth.js: Uncaught Error: Invalid environment variables
at <anonymous> (../../node_modules/@t3-oss/env-core/dist/src-Bb3GbGAa.js:55:56)
at createEnv (../../node_modules/@t3-oss/env-core/dist/src-Bb3GbGAa.js:59:24)
at <anonymous> (../../src/env.ts:23:2)
3 Replies
ballingt
ballingt2mo ago
Oh interesting, do you know where the output goes? Is it in the error message or or stderr or stdout? I'd love to get this right, something like t3env would be really valuable and if that can just be t3env, perfect
jason
jasonOP2mo ago
T3's message is logged via console.error(): https://github.com/t3-oss/t3-env/blob/92d2966dfecbb0d99e6e37be2b01a161a2d6d069/packages/core/src/index.ts#L378 And here is an example console log that I expect to see from T3 env when it can't find a required env var; this example is my vite-based Tanstack app:
2:39:48 AM [vite] src/env.ts changed, restarting server...
❌ Invalid environment variables: [
{
code: 'invalid_type',
expected: 'string',
received: 'undefined',
path: [ 'FOO_BAR' ],
message: 'Required'
}
]
failed to load config from /Users/me/myproj/vite.config.ts
2:39:48 AM [vite] Invalid environment variables
2:39:48 AM [vite] server restart failed
2:39:48 AM [vite] src/env.ts changed, restarting server...
❌ Invalid environment variables: [
{
code: 'invalid_type',
expected: 'string',
received: 'undefined',
path: [ 'FOO_BAR' ],
message: 'Required'
}
]
failed to load config from /Users/me/myproj/vite.config.ts
2:39:48 AM [vite] Invalid environment variables
2:39:48 AM [vite] server restart failed
Maybe Convex's dev server or ESBuild uses try/catch and re-throws somewhere? Here is a simple way to reproduce:
# The versions I have installed right now
bun add -d @t3-oss/env-core@0.13.8 zod@3.25.67
# The versions I have installed right now
bun add -d @t3-oss/env-core@0.13.8 zod@3.25.67
// convex/envConvex.ts
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";

export const envConvex = createEnv({
server: {
FOO_BAR: z.string().min(1),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
// convex/envConvex.ts
import { createEnv } from "@t3-oss/env-core";
import { z } from "zod";

export const envConvex = createEnv({
server: {
FOO_BAR: z.string().min(1),
},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
});
Then use somewhere in code in the convex dir:
// convex/auth.ts
import { envConvex } from "./envConvex";

console.log(envConvex.FOO_BAR);
// convex/auth.ts
import { envConvex } from "./envConvex";

console.log(envConvex.FOO_BAR);
ballingt
ballingt2mo ago
Cool, I can also reproduce with a convex/myFunctions.ts like
import { query } from "./_generated/server";
export const list = query({
handler: async () => {
return 1;
},
});
console.error("this is some error information");
throw new Error("Uninformative error");
import { query } from "./_generated/server";
export const list = query({
handler: async () => {
return 1;
},
});
console.error("this is some error information");
throw new Error("Uninformative error");
which gives me
✖ Error: Unable to push deployment config to http://127.0.0.1:8000
✖ Error fetching POST http://127.0.0.1:8000/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze messages.js: Uncaught Error: Uninformative error
at <anonymous> (../convex/messages.ts:7:37)
✖ Error: Unable to push deployment config to http://127.0.0.1:8000
✖ Error fetching POST http://127.0.0.1:8000/api/push_config 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze messages.js: Uncaught Error: Uninformative error
at <anonymous> (../convex/messages.ts:7:37)
and on the local backend I see
2025-07-11T04:18:07.406618Z INFO convex-cloud-http: [] 127.0.0.1:57800 "POST /api/get_config_hashes HTTP/1.1" 200 "-" "undici" application/json - 0.663ms
2025-07-11T04:18:07.421943Z INFO application: Uploading package with 1 modules to Storage
2025-07-11T04:18:07.441479Z INFO application: Upload of ObjectKey("05526ae1-cdbc-4533-9575-dee9dd35ce92") successful
2025-07-11T04:18:07.441501Z INFO application: Source package size: (Zipped: 57739, Unzipped, 243420)
2025-07-11T04:18:07.443102Z WARN isolate_worker_handle_request: isolate::environment::analyze: Unexpected Console access at import time: 'this is some error information' instance_name="carnitas"
2025-07-11T04:18:07.454761Z ERROR common::errors: Caught error (RUST_BACKTRACE=1 RUST_LOG=info,common::errors=debug for full trace): Hit an error while pushing:\nLoading the pushed modules encountered the following\n error:\nFailed to
analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n: Failed to analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n: Failed to
analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n
2025-07-11T04:18:07.454924Z INFO convex-cloud-http: [] 127.0.0.1:57800 "POST /api/push_config HTTP/1.1" 400 "-" "undici" application/json - 41.837ms
2025-07-11T04:18:07.460887Z INFO convex-cloud-http: [] 127.0.0.1:57822 "GET /api/1.25.3/sync HTTP/1.1" 101 "-" "-" - - 0.192ms
2025-07-11T04:18:07.406618Z INFO convex-cloud-http: [] 127.0.0.1:57800 "POST /api/get_config_hashes HTTP/1.1" 200 "-" "undici" application/json - 0.663ms
2025-07-11T04:18:07.421943Z INFO application: Uploading package with 1 modules to Storage
2025-07-11T04:18:07.441479Z INFO application: Upload of ObjectKey("05526ae1-cdbc-4533-9575-dee9dd35ce92") successful
2025-07-11T04:18:07.441501Z INFO application: Source package size: (Zipped: 57739, Unzipped, 243420)
2025-07-11T04:18:07.443102Z WARN isolate_worker_handle_request: isolate::environment::analyze: Unexpected Console access at import time: 'this is some error information' instance_name="carnitas"
2025-07-11T04:18:07.454761Z ERROR common::errors: Caught error (RUST_BACKTRACE=1 RUST_LOG=info,common::errors=debug for full trace): Hit an error while pushing:\nLoading the pushed modules encountered the following\n error:\nFailed to
analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n: Failed to analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n: Failed to
analyze messages.js: Uncaught Error: Uninformative error\n at <anonymous> (../convex/messages.ts:7:37)\n
2025-07-11T04:18:07.454924Z INFO convex-cloud-http: [] 127.0.0.1:57800 "POST /api/push_config HTTP/1.1" 400 "-" "undici" application/json - 41.837ms
2025-07-11T04:18:07.460887Z INFO convex-cloud-http: [] 127.0.0.1:57822 "GET /api/1.25.3/sync HTTP/1.1" 101 "-" "-" - - 0.192ms
Seems like pushing code to a convex deployment that sends you console.log() messages found during analyze should collect and print the logs, at least on failure. We can probably do that, we've got them, but don't report them (as is apparent from Unexpected Console access at import time: 'this is some error information' instance_name="carnitas")

Did you find this page helpful?