From f1805219234b1678633cc3e7c74f7bf97373b017 Mon Sep 17 00:00:00 2001 From: m1ga Date: Sat, 16 Sep 2023 21:40:57 +0200 Subject: [PATCH] chore: update to new V8Snapshot generator --- android/titanium/libv8-services.js | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/android/titanium/libv8-services.js b/android/titanium/libv8-services.js index 5645a67cff9..ad768266685 100644 --- a/android/titanium/libv8-services.js +++ b/android/titanium/libv8-services.js @@ -171,33 +171,26 @@ async function createSnapshot() { // Requests our server to create snapshot of rolled-up "ti.main" in a C++ header file. let wasSuccessful = false; try { - // Post rolled-up "ti.main" script to server and obtain a snapshot ID as a response. - // We will send an HTTP request for the snapshot code later. + // Post rolled-up "ti.main" script to server and obtain the V8Snapshot.h as a response. console.log('Attempting to request snapshot...'); - const snapshotUrl = 'http://v8-snapshot.appcelerator.com'; // TODO: Migrate to Github Artifacts once ready + const snapshotUrl = 'https://v8-snapshot.titaniumsdk.com/gen'; const packageJsonData = await loadPackageJson(); const requestOptions = { body: { v8: packageJsonData.v8.version, script: rollupFileContent }, - json: true + json: true, + resolveWithFullResponse: true, + timeout: 60 * 1000 * 5 }; - const snapshotId = await request.post(snapshotUrl, requestOptions); - // Request generated snapshot from server using `snapshotId` obtained from server above. const MAX_ATTEMPTS = 20; // Time-out after two minutes. let attempts; for (attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) { - const response = await request.get(`${snapshotUrl}/snapshot/${snapshotId}`, { - simple: false, - resolveWithFullResponse: true - }); + const response = await request.post(snapshotUrl, requestOptions); if (response.statusCode === 200) { - - // Server has finished creating a C++ header file containing all V8 snapshots. - // Write it to file and flag that we're done. console.log('Writing snapshot...'); await fs.writeFile(v8SnapshotHeaderFilePath, response.body); wasSuccessful = true; @@ -208,7 +201,6 @@ async function createSnapshot() { console.log('Waiting for snapshot generation...'); await new Promise(resolve => setTimeout(resolve, 6000)); } else { - // Give up if received an unexpected response. console.error('Could not generate snapshot, skipping...'); break;