puppeteer adapter doesn't capture main frame
I'm trying to use the puppeteer adapter to capture every request on a page (including the root html document, scripts, images, etc..) using:
requestResourceTypes: [
'document', 'stylesheet', 'image', 'media', 'font', 'script', 'texttrack',
'xhr', 'fetch', 'eventsource', 'websocket', 'manifest', 'other'
]
When requestResourceTypes includes document (which matches the main frame/html page), the page hangs indefinitely (or hits timeout)
Platform: macOS v10.11
Node.js: v8.11.4
@pollyjs/adapter-puppeteer: v1.2.0 @pollyjs/core: v1.2.0 @pollyjs/persister-fs: v1.2.0 puppeteer: v1.9.0
'use strict';
const {Polly} = require('@pollyjs/core');
const FSPersister = require('@pollyjs/persister-fs');
const PuppeteerAdapter = require('@pollyjs/adapter-puppeteer');
const puppeteer = require('puppeteer');
Polly.register(FSPersister);
Polly.register(PuppeteerAdapter);
(async () => {
const browser = await puppeteer.launch({headless: false});
const [page] = await browser.pages();
await page.setRequestInterception(true);
const polly = new Polly('hangs', {
adapters: ['puppeteer'],
adapterOptions: {
puppeteer: {
page,
requestResourceTypes: [
'document'
]
}
},
persister: 'fs',
persisterOptions: {
fs: {
recordingsDir: `${__dirname}/recordings`
}
},
recordFailedRequests: true,
logging: true
});
await page.goto('http://www.example.com/', {
waitUntil: 'networkidle2',
timeout: 0
});
await page.close();
await browser.close();
await polly.stop();
})();
Also, if I manually modify the recording.har file to add an entry for https://www.example.com/, it will correctly replay it. It's only when recording the request that it hangs.
@kiavashps thanks for the detailed description on this issue. Does the page still hang if you set the resource types to ['xhr', 'fetch', 'document', 'other']?
Polly does not currently capture all of those resource types. Only xhr, fetch, and other (partially) are supported resource types. Perhaps we should warn when other options are passed for requestResourceTypes.
Closing for now.
I guess this is still the case. Are there any plans on adding support for the document resource type?
Right now the scope of this project is to capture requests through xhr and fetch using the puppeteer adapter. In the future we may expand this to include other types.