-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config: Expected VALUE to exist in the process context #3427
Comments
It"s not a bug of Effect You can"t access environment variables in the browser dynamically However, you can create a "use client";
import { useEffect } from "react";
import { Config, Effect, ConfigProvider } from "effect";
const NextConfigProvider = ConfigProvider.fromMap(
new Map([
[
//
"NEXT_PUBLIC_CONFIG_VALUE",
process.env.NEXT_PUBLIC_CONFIG_VALUE!, // <-- will be inlined by Next
],
])
);
export default function Home() {
useEffect(() => {
console.log("process.env", process.env.NEXT_PUBLIC_CONFIG_VALUE);
const result = Effect.runSync(
Config.string("NEXT_PUBLIC_CONFIG_VALUE").pipe(
Effect.withConfigProvider(NextConfigProvider)
)
);
console.log("effect", result);
}, []);
return <div>{process.env.NEXT_PUBLIC_CONFIG_VALUE}</div>;
} Or you can use |
You"re right. Forgot about that. Sorry. The only thing is that it doesn"t work in Convex Runtime, which is not a browser. The worst part about that is that it would be hard to create an easily accessible reproduction. For now, I use the following workaround: const api_key = yield* Config.redacted("API_KEY").pipe(
Config.withDefault(
Redacted.make(process.env["API_KEY"] ?? ""),
),
) |
For environments that require static access you"ll need a custom provider and to list explicitely the env variables, nothing we can do. Would be good to open this issue in convex to see if there is a prefix like next that would automatically inline variables |
What version of Effect is running?
3.6.1
What steps can reproduce the bug?
Open the reproduction
What is the expected behavior?
I want the value from the config to be resolved
What do you see instead?
(FiberFailure) Error: (Missing data at NEXT_PUBLIC_CONFIG_VALUE: "Expected NEXT_PUBLIC_CONFIG_VALUE to exist in the process context")
Additional information
Initially, I received this error implementing a Convex Function. However,
process.env
also worked fine there. So I decided to create a reproduction. Unfortunately, it doesn"t work too.The text was updated successfully, but these errors were encountered: