zawa
zawa
CDCloudflare Developers
Created by zawa on 8/27/2024 in #workers-help
Intermittent Errors Related to Permissions-Policy Header
I am developing an API using Cloudflare Workers and leveraging a free Cloudflare account. This API stores the accessed IP addresses into KV storage, utilizing the features of Workers and KV. Generally, it functions correctly, but occasionally, during certain periods, I encounter the following errors in the console, and the response is not returned. Could you help me identify the cause and provide any possible fixes?
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'run-ad-auction'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'private-state-token-redemption'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'private-state-token-issuance'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'join-ad-interest-group'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'browsing-topics'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'run-ad-auction'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'private-state-token-redemption'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'private-state-token-issuance'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'join-ad-interest-group'.
Error with Permissions-Policy header: Origin trial controlled feature not enabled: 'browsing-topics'.
2 replies
CDCloudflare Developers
Created by zawa on 4/17/2024 in #workers-help
I cannot pass `env.MYBROWSER` as an argument to `puppeteer.launch`.
I have a question regarding TypeScript and trying to use puppeteer. I am encountering a type error. In the following sample code, I cannot pass env.MYBROWSER as an argument to puppeteer.launch.
import puppeteer from "@cloudflare/puppeteer";

interface Env {
MYBROWSER: Fetcher;
}

export default {
async fetch(request: Request, env: Env): Promise<Response> {
const browser = await puppeteer.launch(env.MYBROWSER);
const page = await browser.newPage();
await page.goto("https://example.com");
const metrics = await page.metrics();
await browser.close();
return Response.json(metrics);
},
};
import puppeteer from "@cloudflare/puppeteer";

interface Env {
MYBROWSER: Fetcher;
}

export default {
async fetch(request: Request, env: Env): Promise<Response> {
const browser = await puppeteer.launch(env.MYBROWSER);
const page = await browser.newPage();
await page.goto("https://example.com");
const metrics = await page.metrics();
await browser.close();
return Response.json(metrics);
},
};
The error message for the argument is as follows:
The argument of type '{ fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>; connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket; }' cannot be assigned to the parameter of type 'BrowserWorker'.
The type returned by 'fetch(...)' is not compatible between these types.
Type 'Promise<Response>' cannot be assigned to type 'Promise<global.Response>'.
Property 'type' does not exist on type 'Response' but is required in type 'import("path/node_modules/undici-types/fetch").Response'.ts(2345)
fetch.d.ts(191, 12): 'type' is declared here.
(property) Env.MYBROWSER: {
fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>;
connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket;
}
The argument of type '{ fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>; connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket; }' cannot be assigned to the parameter of type 'BrowserWorker'.
The type returned by 'fetch(...)' is not compatible between these types.
Type 'Promise<Response>' cannot be assigned to type 'Promise<global.Response>'.
Property 'type' does not exist on type 'Response' but is required in type 'import("path/node_modules/undici-types/fetch").Response'.ts(2345)
fetch.d.ts(191, 12): 'type' is declared here.
(property) Env.MYBROWSER: {
fetch(input: RequestInfo<unknown, CfProperties<unknown>>, init?: RequestInit<CfProperties<unknown>> | undefined): Promise<Response>;
connect(address: string | SocketAddress, options?: SocketOptions | undefined): Socket;
}
Is there a solution to this issue?
12 replies