1- import fetch from "cross-fetch" ;
21import { configDotenv } from "dotenv" ;
32
43configDotenv ( { quiet : true } ) ;
@@ -39,7 +38,7 @@ async function createAccount() {
3938 const vaultHost = `${ VAULT_HOST_URL } :${ VAULT_HOST_PORT } ` ;
4039
4140 try {
42- const requestOptions = {
41+ const requestOptions : RequestInit = {
4342 headers : {
4443 accept : "application/json" ,
4544 "content-type" : "application/json; charset=utf-8" ,
@@ -55,8 +54,13 @@ async function createAccount() {
5554 } ,
5655 ) ;
5756
58- const preCreationResponseData =
59- ( await preCreationResponse . json ( ) ) as PreAccountCreateResponseData ;
57+ const rawText1 = await preCreationResponse . text ( ) ;
58+ console . log (
59+ `[debug] step1 status=${ preCreationResponse . status } body=${ rawText1 . slice ( 0 , 500 ) } ` ,
60+ ) ;
61+ const preCreationResponseData = JSON . parse (
62+ rawText1 ,
63+ ) as PreAccountCreateResponseData ;
6064
6165 if (
6266 typeof preCreationResponseData !== "string" &&
@@ -117,14 +121,18 @@ async function createAccount() {
117121 } ,
118122 ) ;
119123
120- const responseData = ( await response . json ( ) ) as AccountCreationResponseData ;
124+ const rawText2 = await response . text ( ) ;
125+ console . log (
126+ `[debug] step2 status=${ response . status } body=${ rawText2 . slice ( 0 , 500 ) } ` ,
127+ ) ;
128+ const responseData = JSON . parse ( rawText2 ) as AccountCreationResponseData ;
121129
122130 if ( responseData . object === "registerFinish" ) {
123131 emitSuccessMessage ( vaultHost ) ;
124132 return ;
125133 }
126134 } catch ( error ) {
127- // Server isn't ready yet
135+ console . log ( "[debug] caught:" , error ) ;
128136 }
129137
130138 console . log ( `Retrying account creation at ${ vaultHost } ...` ) ;
0 commit comments