Panel saving page works but refresh icon keeps spinning

i have a panel hook attached to updating a page. saving the page and calling the hook works. all code is executed. the executed code creates a file and that may take a few seconds.

but the refresh icon in the upper right corner of the panel keeps spinning forever. changing the edited page via the menu to the left does not fix it. nothing i tried did, but logout of panel.
what could my code be doing wrong to cause the refresh icon to fail from responding again?

It would help if you could post all your relevant code, i.e. the blueprint and the hook.

while compiling the code to post it here i found the solution.

my code send new headers to download the pdf file when the page was viewed. but

  • a) setting the header this should not happen when updating from the panel, just writing the file.
  • b) nor should the pdf-lib be called when working on localhost panel since it does not work then.

like this a)

header("Content-Type: application/pdf"); echo $pdf;

config.php the hook and for b)

function is_localhost() {
    $whitelist = array( '', '::1' );
    if( in_array( $_SERVER['REMOTE_ADDR'], $whitelist) )
        return true;

function checkIfPageNeedsPdfUpdate($site, $page) {
    if(is_localhost()) return;
	if(in_array($page->template(), array('print'))) {
		generatePDF($site, $page, 'a3', true, true);