Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tidy-bobcats-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-shared": minor
---

Limit free tier requests in the Router worker
3 changes: 3 additions & 0 deletions packages/workers-shared/router-worker/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ type Data = {
staticRoutingDecision?: STATIC_ROUTING_DECISION;
// double7 - Whether the request was blocked by abuse mitigation or not
abuseMitigationBlocked?: boolean;
// double8 - User worker invocation denied due to free tier limiting
userWorkerFreeTierLimiting?: boolean;

// -- Blobs --
// blob1 - Hostname of the request
Expand Down Expand Up @@ -93,6 +95,7 @@ export class Analytics {
: Number(this.data.userWorkerAhead),
this.data.staticRoutingDecision ?? STATIC_ROUTING_DECISION.NOT_PROVIDED, // double6
this.data.abuseMitigationBlocked ? 1 : 0, // double7
this.data.userWorkerFreeTierLimiting ? 1 : 0, // double8
],
blobs: [
this.data.hostname?.substring(0, 256), // blob1 - trim to 256 bytes
Expand Down
14 changes: 12 additions & 2 deletions packages/workers-shared/router-worker/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { RouterConfig } from "../../utils/types";
import type { EyeballRouterConfig, RouterConfig } from "../../utils/types";

export const applyConfigurationDefaults = (
type RequiredEyeballRouterConfig = Required<Exclude<EyeballRouterConfig, null>>;

export const applyRouterConfigDefaults = (
configuration?: RouterConfig
): Required<RouterConfig> => {
return {
Expand All @@ -15,3 +17,11 @@ export const applyConfigurationDefaults = (
},
};
};

export const applyEyeballConfigDefaults = (
eyeballConfiguration?: EyeballRouterConfig
): RequiredEyeballRouterConfig => {
return {
limitedAssetsOnly: eyeballConfiguration?.limitedAssetsOnly ?? false,
};
};
Loading
Loading