Adding token offsets to SQLite syntax errors If you've used SQLite's shell before, you might be used to errors like this when there's an issue with the syntax of the query. Parse error: near "(": syntax error eated timestamp NOT NULL DEFAULT current_timestamp(), lastchange timestamp N error here ---^ You might still be a little confused why
Using Cloudflare Hyperdrive with tokio-postgres in Workers Cloudflare recently announced their query caching & connection pooling solution for databases in Workers, Hyperdrive. Whilst there's plenty of examples of using Hyperdrive with libraries like pg in the documentation, someone in the Cloudflare Developers Discord asked about usability with Rust Workers. There are examples for using tokio-postgres with workers-rs, the
Cloudflare Workers - using AsyncLocalStorage for request context Cloudflare Workers recently implemented a subset of Node modules, one of these is AsyncLocalStorage! One of the most common examples out there is using AsyncLocalStorage to add request context, like an ID for log items, to identify log messages that are related to the same request which can be hard
Cloudflare Workers - How long does an isolate last for? If you're using Cloudflare Workers or have been reading through the documentation to see if they're right for you, you've probably seen a lot about 'isolates' and 'eviction' - but what does that actually mean? Isolates Cloudflare Workers leverages the V8 JavaScript engine, used primarily in Chromium. The Design of
Cloudflare workerd - generating configs ahead of time If you're not familiar with Cloudflare Workers already, it's a serverless platform that leverages the V8 runtime & isolate model to provide super fast execution at a nanoservice level. In September 2022, the runtime was made publicly available as workerd. The launch blog provides some background & context, and I highly recommend
Cloudflare's Transparent Decompression - how does it work? I've seen a few topics or questions around compressed files being downloaded as plain-text or missing Content-Length headers recently so I thought it'd be a good idea to write about why this happens and how the behaviour is controlled. Cloudflare is, at it's core, a Content Delivery Network - but
Cloudflare Workers - Build time constants with Wrangler Replacing global identifiers with build-time constants has a few uses - inserting a Git hash or release number for using with Sentry SDKs or eliding away code that is only meant for development & staging environments. Wrangler, the Cloudflare Workers command-line tool, exposes a few esbuild APIs that we can interact
CryptoKey bindings in Cloudflare Workers - importKey at publish time! If you use the Web Crypto API, chances are you're using importKey - this is an async method that takes the format, usages, algorithm & the key and gives you a CryptoKey object. If your key is never changing (or very infrequently), having to import on every request is wasteful -
Cloudflare R2 and AWS's SDK for .NET PutObject - STREAMING-AWS-HMAC-SHA256-PAYLOAD If you've tried to use the AWSSDK.S3 package for interacting with Cloudflare R2 from .NET, you've likely ran into this error when uploading a file using PutObject: STREAMING-AWS-HMAC-SHA256-PAYLOAD This is since R2 doesn't support Streaming SigV4 which is used in chunked uploading. The fix for this
Configuring CORS on Cloudflare R2 Not being able to configure Cross-Origin Resource Sharing (CORS) has been a thorn in the side of many developers. Whilst you could work around it using Transform Rules for public buckets, a common pain point is needing CORS to be able to use presigned URLs for client uploads. In yesterday's
103 Early Hints - what file types can leverage them? When writing the Early Hints Worker, I added in the 3 valid 'as' attributes that I know of - image, script and style. This worked just fine for my use-case as I only intended to preload those assets, but I was curious as to what else can leverage Early Hints.
Exposing development environments over HTTPS using Cloudflare Tunnels At some point, the majority of developers will run into a scenario where they're looking to add automation tests to a payment gateway on their website - this requires two things, usually for callbacks/webhooks: 1) Dealing with port-forwarding, which is something that no IT or DevOps team want to
Implementing 103 Early Hints with Cloudflare Workers & HTMLRewriter! Part 1 What are 103 Early Hints? 103 Early Hints, a new informational HTTP status code to provide resource hints to clients before the final response is ready, has landed in Chrome 103. If you haven't already read the blog from Cloudflare about how it works & their performance benchmarks, you definitely should!
Progressive S3 to Cloudflare R2 migration using Workers R2, Cloudflare's competitor to S3 and other object stores, is now in open beta [https://blog.cloudflare.com/r2-open-beta/]! In my opinion, there's three things that make R2 stand out from the rest: 1. There are no egress fees. Yep, absolutely none - you are only charged for storage and