Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: How to run Astral in Deno Deploy w/ external providers #140

Open
janzheng opened this issue Feb 4, 2025 · 4 comments
Open

Docs: How to run Astral in Deno Deploy w/ external providers #140

janzheng opened this issue Feb 4, 2025 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@janzheng
Copy link

janzheng commented Feb 4, 2025

Hi there!

I've been running Astral locally and it's been great, but on Deno Deploy I keep getting:

Requires write access to /src/.cache/astral, which cannot be granted in this environment

It seems like other people have figured out how to put Astral on Deno Deploy, so I'm wondering what I need to do?

Basically my code is:


import { launch } from "jsr:@astral/astral";

const generateDocument = async (html: string, options: any = {}) => {
  const browser = await launch();
  const page = await browser.newPage("about:blank");
  
  await page.evaluate((data) => {
    document.documentElement.innerHTML = data.html;
  }, {
    args: [{ html }]
  });

  // Wait for any styles/fonts to load
  await page.waitForTimeout(options.timeout || 2500);

  let result;
  if (options.type === 'pdf') {
    result = await page.pdf({
      format: options.format || 'Letter',
      printBackground: true,
      margin: options.margin || {
        top: '1cm',
        right: '1cm',
        bottom: '1cm',
        left: '1cm'
      }
    });
  } else {
    result = await page.screenshot(options.screenshotOptions);
  }

  await browser.close();
  return result;
};
@lino-levan
Copy link
Owner

Unfortunately, Deploy does not support running arbitrary binaries. Astral works in deploy through a third-party provider like browserless.

@lino-levan lino-levan added the question Further information is requested label Feb 4, 2025
@janzheng
Copy link
Author

janzheng commented Feb 4, 2025

oh good tip, thank you!

@janzheng
Copy link
Author

janzheng commented Feb 4, 2025

I'm messing around with Browserless and the examples, passing in the token, etc. — I'm getting a connection and result on a regular POST call (to Browserless v2 API) but somehow on the wss: endpoint it just hangs on launch(), and I can't even seem to be able to close the connection. It might just be a Browserless error, but I'm clueless how to continue, so I'll just keep running locally and using a local tunnel.

Thanks for the help, I'm sure other people have gotten this working lol so I'm just going to close this.

@janzheng janzheng closed this as completed Feb 4, 2025
@lino-levan lino-levan added documentation Improvements or additions to documentation and removed question Further information is requested labels Feb 4, 2025
@lino-levan
Copy link
Owner

I'm hoping to write up better docs for this. Thanks for flagging.

@lino-levan lino-levan reopened this Feb 4, 2025
@lino-levan lino-levan changed the title Deno Deploy "Requires write access to /src/.cache/astral, which cannot be granted in this environment" Docs: How to run Astral in Deno Deploy w/ external providers Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants