Skip to content

Commit c89e655

Browse files
committed
feat: build lint/tsc cache in background on sandbox init
1 parent 3ef0ce9 commit c89e655

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

worker/services/sandbox/sandboxSdkClient.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -805,27 +805,17 @@ export class SandboxSdkClient extends BaseSandboxService {
805805

806806
// Allocate single port for both dev server and tunnel
807807
const allocatedPort = await this.allocateAvailablePort();
808-
809-
// Start cloudflared tunnel using the same port as dev server
810-
// const tunnelPromise = this.startCloudflaredTunnel(instanceId, allocatedPort);
811-
808+
812809
this.logger.info('Installing dependencies', { instanceId });
813810
const installResult = await this.executeCommand(instanceId, `bun install`);
814811
this.logger.info('Dependencies installed', { instanceId });
815812

816813
if (installResult.exitCode === 0) {
817814
// Try to start development server in background
818815
try {
819-
// Set local environment variables if provided
820-
// if (localEnvVars) {
821-
// await this.setLocalEnvVars(instanceId, localEnvVars);
822-
// }
823816
// Initialize git repository
824817
await this.executeCommand(instanceId, `git init`);
825818
this.logger.info('Git repository initialized', { instanceId });
826-
// this.logger.info(`Running setup script for ${instanceId}`);
827-
// const setupResult = await this.executeCommand(instanceId, `[ -f setup.sh ] && bash setup.sh ${projectName}`);
828-
// this.logger.info(`Setup result: STDOUT: ${setupResult.stdout}, STDERR: ${setupResult.stderr}`);
829819
// Start dev server on allocated port
830820
const processId = await this.startDevServer(instanceId, allocatedPort);
831821
this.logger.info('Instance created successfully', { instanceId, processId, port: allocatedPort });
@@ -839,10 +829,15 @@ export class SandboxSdkClient extends BaseSandboxService {
839829
previewURL = previewURL.replace(env.CUSTOM_DOMAIN, previewDomain);
840830
}
841831

842-
// Wait for tunnel URL (tunnel forwards to same port)
843-
// const tunnelURL = await tunnelPromise;
844-
845832
this.logger.info('Preview URL exposed', { instanceId, previewURL });
833+
834+
// In the background, run an iteration of static analysis to build up cache
835+
Promise.allSettled([
836+
this.executeCommand(instanceId, `bun run lint`),
837+
this.executeCommand(instanceId, `bunx tsc -b --incremental --noEmit --pretty false`)
838+
]).then(() => {
839+
this.logger.info('Static analysis completed', { instanceId });
840+
});
846841

847842
return { previewURL, tunnelURL: '', processId, allocatedPort };
848843
} catch (error) {

0 commit comments

Comments
 (0)