PDFPipe

It will not run

Protocol error (Page.printToPDF): Target closed

The render starts, and partway through the browser tab disappears. The error names the print call because that is what was in flight, which sends people looking at the print options when the page died for an unrelated reason.

What is actually happening

The tab crashed, and by far the most common reason is memory. A large document with many images can exceed what the container allows, and the tab is killed rather than the process, so you get a protocol error rather than an out-of-memory message.

Confirming it is this and not something that looks like it

Watch memory during a render that fails. If it climbs to the container limit and the error follows, that is the whole story.

The fix

Reduce what the page holds in memory, chiefly by resizing images before embedding them, and give the container enough headroom. A browser is not a lightweight process and sizing a container for the application rather than for the browser is the usual mistake.

If that was not it

These produce the same symptom often enough to be worth ruling out before assuming the fix above did not work.

  • A /dev/shm smaller than 64MB, the container default, which the browser uses heavily
  • Concurrency: several renders at once multiply the memory requirement
  • Exit code 137, which is the OOM killer and confirms the diagnosis
  • A page with thousands of DOM nodes, such as an unpaginated table of every transaction

Frequently asked

Does this happen with every rendering engine?

The behaviour behind it is not specific to one tool. The tab crashed, and by far the most common reason is memory. Anything rendering HTML to a paged medium has to make the same decision, so the fix travels with you if you change how the render happens.

Will this show up as an error in my logs?

Yes, this one surfaces as a thrown error or a failed status, which is why it is at least findable. The harder half is that the message often names the call that was in flight rather than the thing that actually failed.

Related failures

Problems people arrive at from the same starting point, or mistake for this one.

Paste your markup and see the rendered document, without signing up.