File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,6 +136,38 @@ export default abstract class BaseDeployCommand extends CloudInstanceCommand {
136136 timeoutMs : deployTimeoutMs
137137 } ) ;
138138
139+ /**
140+ * We typically want to perform a sync config validation after a (re)provision.
141+ * Even though we wait for the deploy operation above, the request to validate sync config
142+ * can still fail due to the error
143+ * [INTERNAL_SERVER_ERROR] Something went wrong
144+ * getaddrinfo ENOTFOUND 69b8fec1358aa0646ff0ce71.powersync.journeyapps.com
145+ * Which indicates that the API runner is not active yet.
146+ * For this reason, we poll the diagnostics API until we get some successful response from the API
147+ */
148+ for ( let retryCount = 0 ; retryCount < 5 ; retryCount ++ ) {
149+ try {
150+ const { linked } = this . project ;
151+ await this . client . getInstanceDiagnostics ( {
152+ app_id : linked . project_id ,
153+ id : linked . instance_id ,
154+ org_id : linked . org_id
155+ } ) ;
156+ // We reached the instance
157+ break ;
158+ } catch {
159+ if ( retryCount === 4 ) {
160+ throw new Error (
161+ 'Failed to reach instance after provision. Please check the instance status and try again.'
162+ ) ;
163+ }
164+
165+ await new Promise < void > ( ( resolve ) => {
166+ setTimeout ( resolve , 5000 ) ;
167+ } ) ;
168+ }
169+ }
170+
139171 spinner . stop ( ) ;
140172 } catch ( error ) {
141173 spinner . stop ( ) ;
You can’t perform that action at this time.
0 commit comments