@@ -70,8 +70,8 @@ if (!templateID) {
7070 throw new Error ( "❌ Template ID not found in e2b.toml" ) ;
7171}
7272
73- // sleep for 5 seconds to create a time delta
74- await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
73+ // sleep for 15 seconds to create a time delta
74+ await new Promise ( ( resolve ) => setTimeout ( resolve , 15000 ) ) ;
7575
7676try {
7777 // remove the file to make script idempotent in local testing
@@ -88,15 +88,15 @@ try {
8888
8989 console . log ( "ℹ️ starting command" ) ;
9090 const localDate = new Date ( ) . getTime ( ) / 1000 ;
91- const date = await sandbox . commands . run ( "date +%s" ) ;
91+ const date = await sandbox . commands . run ( "date +%s%3N " ) ;
9292 console . log ( "localDate" , localDate ) ;
9393
9494 console . log ( "date" , date . stdout ) ;
95- const dateUnix = parseInt ( date . stdout ) ;
95+ const dateUnix = parseFloat ( date . stdout ) / 1000 ;
9696 console . log ( "ℹ️ comparing dates" , dateUnix , localDate ) ;
9797
98- // compare the dates, should be within 1 second
99- if ( Math . abs ( dateUnix - localDate ) > 1 ) {
98+ // compare the dates, should be within 2 second
99+ if ( Math . abs ( dateUnix - localDate ) > 2 ) {
100100 throw new Error ( "❌ Date is not synchronized" ) ;
101101 }
102102
@@ -107,8 +107,7 @@ try {
107107} catch ( e ) {
108108 console . error ( "Error while running sandbox or commands" , e ) ;
109109 throw e ;
110- } finally {
111- // delete template
110+ } finally { // delete template
112111 const output = await streamCommandOutput ( "deno" , [
113112 "run" ,
114113 "--allow-all" ,
0 commit comments