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
fix: do not crash in wrangler dev if user has multiple accounts
When a user has multiple accounts we show a prompt to allow the user to select which they should use.
This was broken in wrangler dev as we were trying to start a new ink.js app (to show the prompt)
from inside a running ink.js app (the UI for wrangler dev).
This fix refactors the ChooseAccount component so that it can be used directly within another component.
Fixes#1258
"Failed to automatically retrieve account IDs for the logged in user.\n"+
36
+
"In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as `account_id` in your `wrangler.toml` file."
37
+
)
38
+
);
39
+
}elseif(response.length===1){
40
+
props.onSelect(response[0].account.id);
41
+
}elseif(props.isInteractive){
42
+
setAccounts(response.map((x)=>x.account));
43
+
}else{
44
+
props.onError(
45
+
newError(
46
+
"More than one account available but unable to select one in non-interactive mode.\n"+
47
+
`Please set the appropriate \`account_id\` in your \`wrangler.toml\` file.\n`+
"Failed to automatically retrieve account IDs for the logged in user.\n"+
1090
-
"In a non-interactive environment, it is mandatory to specify an account ID, either by assigning its value to CLOUDFLARE_ACCOUNT_ID, or as `account_id` in your `wrangler.toml` file."
1091
-
);
1092
-
}
1093
-
if(accounts.length===1){
1094
-
accountId=accounts[0].account.id;
1095
-
}elseif(isInteractive){
1096
-
accountId=awaitnewPromise((resolve)=>{
1097
-
constaccountIds=accounts.map((x)=>x.account);
1098
-
const{ unmount }=render(
1099
-
<ChooseAccount
1100
-
accounts={accountIds}
1101
-
onSelect={async(selected)=>{
1102
-
resolve(selected.value.id);
1103
-
unmount();
1104
-
}}
1105
-
/>
1106
-
);
1107
-
});
1108
-
}else{
1109
-
thrownewError(
1110
-
"More than one account available but unable to select one in non-interactive mode.\n"+
1111
-
`Please set the appropriate \`account_id\` in your \`wrangler.toml\` file.\n`+
0 commit comments