You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading the alpaca-trade-api dotenv is called on the first line of dist/alpaca-trade-api.js
This means if you have a custom dotenv setup eg. different tokens for dev vs prod or multiple dotenv files you aren't able to guarantee a specific configuration. Depending on module load order, alpaca sometimes has won out. This has caused me to patch alpaca and delete that line.
When I load alpaca, I can use my own method to load in environment variables and init them into alpaca. At minimum some way to disable this behavior would be great.
SDK Version I encountered this issue in
"@alpacahq/alpaca-trade-api": "^3.1.3"
Steps To Reproduce
1. Create a package with a 2 dotenv files, load them in a custom way eg:
import dotenv from "dotenv";
if (process.env.NODE_ENV === "development") {
dotenv.config({ path: "../.env.dev" });
}
dotenv.config({ path: "../.env" });
2. Import this file and alpaca
3. Notice alpaca wins depending on dependency graph (I don't totally know what it takes for alapaca to get loaded first)
Filled out the Steps to Reproduce section?
I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.
Anything else?
Sorry for posting a bunch of issues at once - figured i drop in all the notes while i was here :)
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current Behavior
When loading the alpaca-trade-api dotenv is called on the first line of dist/alpaca-trade-api.js
This means if you have a custom dotenv setup eg. different tokens for dev vs prod or multiple dotenv files you aren't able to guarantee a specific configuration. Depending on module load order, alpaca sometimes has won out. This has caused me to patch alpaca and delete that line.
My pnpm patch for reference
Expected Behavior
When I load alpaca, I can use my own method to load in environment variables and init them into alpaca. At minimum some way to disable this behavior would be great.
SDK Version I encountered this issue in
"@alpacahq/alpaca-trade-api": "^3.1.3"
Steps To Reproduce
Filled out the Steps to Reproduce section?
Anything else?
Sorry for posting a bunch of issues at once - figured i drop in all the notes while i was here :)
The text was updated successfully, but these errors were encountered: