Skip to content

Commit

Permalink
Merge pull request #98 from pwa-builder/dev
Browse files Browse the repository at this point in the history
Disabling speed optimizations on Report
  • Loading branch information
khmyznikov authored Dec 13, 2023
2 parents b8aad89 + a34a16e commit f4e077f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ChildProcess, exec, spawn } from 'child_process';
const __dirname = dirname(fileURLToPath(import.meta.url));
// const _root = `${__dirname}/../..`;

const AZURE_FUNC_TIMEOUT = 2 * 60 * 1000;
const AZURE_FUNC_TIMEOUT = 3 * 60 * 1000;
const SPAWN_TIMEOUT = AZURE_FUNC_TIMEOUT - 15 * 1000;

const httpTrigger: AzureFunction = async function (
Expand Down
80 changes: 41 additions & 39 deletions Report/lighthouse/lighthouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,46 +137,48 @@ async function execute() {
});

page.on('request', (req) => {
const resourceType = req.resourceType();
if (SKIP_RESOURCES.some((type) => resourceType == type)){
switch (resourceType) {
case 'image':
req.respond(
{
status: 200,
contentType: 'image/jpeg',
body: Buffer.from(base64Image, 'base64'),
});
break;
case 'font':
req.respond(
{
status: 200,
contentType: 'font/woff2',
body: Buffer.from(base64Font, 'base64'),
// commented because it doesn't work on Azure environment
// const resourceType = req.resourceType();
// if (SKIP_RESOURCES.some((type) => resourceType == type)){
// let contentType = req.headers().accept?.split(',')[0] || 'text/plain';
// switch (resourceType) {
// case 'image':
// req.respond(
// {
// status: 200,
// contentType,
// body: Buffer.from(base64Image, 'base64'),
// });
// break;
// case 'font':
// req.respond(
// {
// status: 200,
// contentType,
// body: Buffer.from(base64Font, 'base64'),

});
break;
case 'fetch':
if (req.method() == 'GET')
req.respond({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ success: true, message: "Intercepted fetch request" }),
});
else
req.continue();
break;
default:
req.respond({
status: 200,
contentType: 'text/plain',
body: '{"success": true}',
});
break;
}
}
else
// });
// break;
// case 'fetch':
// if (req.method() == 'GET')
// req.respond({
// status: 200,
// contentType,
// body: JSON.stringify({ success: true, message: "Intercepted fetch request" }),
// });
// else
// req.continue();
// break;
// default:
// req.respond({
// status: 200,
// contentType,
// body: '{"success": true}',
// });
// break;
// }
// }
// else
req.continue();
});

Expand Down
1 change: 0 additions & 1 deletion tests/test_urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"https://nute.app/",
"https://garfieldapp.tk/",
"https://microsoftedge.github.io/Demos/wami/",
"https://app.mapbuddy.app/",
"https://breedershub.in",
"https://ril.kryptografische.biz/",
"https://cryptojam.net",
Expand Down

0 comments on commit f4e077f

Please sign in to comment.