question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] ETXTBSY with README example

See original GitHub issue

Environment

  • chrome-aws-lambda Version: 8.0.1
  • puppeteer / puppeteer-core Version: 8.0.0
  • OS: Linux
  • Node.js Version: 14.x
  • Lambda / GCF Runtime: Node.js 14.x

Expected Behavior

Chromium launches successfully.

Current Behavior

The following error returned when testing in AWS console:

{
  "errorType": "Error",
  "errorMessage": "spawn ETXTBSY",
  "trace": [
    "Error: spawn ETXTBSY",
    "    at ChildProcess.spawn (internal/child_process.js:403:11)",
    "    at Object.spawn (child_process.js:553:9)",
    "    at BrowserRunner.start (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:79:34)",
    "    at ChromeLauncher.launch (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Launcher.js:86:16)",
    "    at async Runtime.exports.handler (/var/task/index.js:8:15)"
  ]
}```

## Steps to Reproduce

I copied exactly the example from the README:

```js
const chromium = require('chrome-aws-lambda');

exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

  try {
    browser = await chromium.puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true,
    });

    let page = await browser.newPage();

    await page.goto(event.url || 'https://example.com');

    result = await page.title();
  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }

  return callback(null, result);
};

I tried the answer here, clearing my node_modules and running npm install --no-bin-links, and it had no effect for me.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yujiri8commented, Apr 3, 2021

TL;DR my problem is solved.

I hadn’t thought of the memory limit. Changing it from 128MB to 1024MB led to this:

START RequestId: 1094543c-0295-46d3-98ff-6df94c41dd8b Version: $LATEST
END RequestId: 1094543c-0295-46d3-98ff-6df94c41dd8b
REPORT RequestId: 1094543c-0295-46d3-98ff-6df94c41dd8b	Duration: 3003.58 ms	Billed Duration: 3000 ms	Memory Size: 1024 MB	Max Memory Used: 398 MB	Init Duration: 184.45 ms	
2021-04-03T15:37:52.790Z 1094543c-0295-46d3-98ff-6df94c41dd8b Task timed out after 3.00 seconds

And on second run:

START RequestId: 78c3e307-17d9-461b-b338-66ea30d48ba2 Version: $LATEST
2021-04-03T15:38:13.624Z	78c3e307-17d9-461b-b338-66ea30d48ba2	ERROR	Invoke Error 	{"errorType":"Error","errorMessage":"Failed to launch the browser process!\n\n\nTROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md\n","stack":["Error: Failed to launch the browser process!","","","TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md","","    at onClose (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)","    at Interface.<anonymous> (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)","    at Interface.emit (events.js:327:22)","    at Interface.close (readline.js:424:8)","    at Socket.onend (readline.js:202:10)","    at Socket.emit (events.js:327:22)","    at endReadableNT (internal/streams/readable.js:1327:12)","    at processTicksAndRejections (internal/process/task_queues.js:80:21)"]}
END RequestId: 78c3e307-17d9-461b-b338-66ea30d48ba2
REPORT RequestId: 78c3e307-17d9-461b-b338-66ea30d48ba2	Duration: 298.83 ms	Billed Duration: 299 ms	Memory Size: 1024 MB	Max Memory Used: 28 MB	

But if I also increase the timeout, it succeeds in:

START RequestId: fb3ce2bb-3708-42a5-88a4-fe8cdd9d908d Version: $LATEST
END RequestId: fb3ce2bb-3708-42a5-88a4-fe8cdd9d908d
REPORT RequestId: fb3ce2bb-3708-42a5-88a4-fe8cdd9d908d Duration: 3887.04 ms Billed Duration: 3888 ms Memory Size: 1024 MB Max Memory Used: 437 MB Init Duration: 216.92 ms

I’ll close the issue. Thanks for your help!

0reactions
alixaxelcommented, Apr 3, 2021

@yujiri8 I uploaded your Zip file and it ran successfully for me:

image

Are you allocating enough memory (> 512MB) to your Lambda?


As for 8.0.2, it only introduced a fix to the Makefile and an additional overloaded method, so it can’t be the culprit of this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] ETXTBSY when launching · Issue #187 - GitHub
Simple lambda reads HTML from event.body and returns PDF stream. Intended to be wired up to api-gateway. With a test event it will...
Read more >
How to write a good README for your GitHub project?
Today we will focus on good practices of writing such a file - with a few examples, and a ready to use template....
Read more >
README File – Everything you Need to Know - Great Learning
A README file is a text file that describes and launches a project. It comprises information that is frequently needed to grasp the...
Read more >
README.md template | Documenting your project - Drupal
Information about content and formatting of project README files. ... Submit bug reports and feature suggestions, or track changes in the [issue ...
Read more >
Error Pages - ReadMe Documentation
You can create custom error pages to display to your users if they try, for example, to access a broken link. Found under...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found