Workers scripts: Errors do not get printed to the terminal

I am posting this to help others who run into this issue.

I am using try/catch blocks in my Workers scripts. I run wrangler dev in my terminal to run my Workers in a development environment. If an error occurs in my Worker script, then an error will get thrown but nothing will get printed to the terminal. If I console.log(err) in the catch block, then the only thing that gets printed to the terminal is error. There is no error message. I finally discovered that you have to type console.log(err.toString()) to print the error in the catch block.

I don’t know if that is a common thing in other JavaScript environments, but I have never come across that - I have never had to type err.toString() to log an error to the console. I was about to use a different serverless platform because I could not figure out a couple of basic programming things like that in the Workers environment.

There has got to be a better getting started guide that walks n00bies through the process of using Workers. Basic things like this need to be addressed. Also, the way you parse route params should be explained too:

const handler = async (request) => {
  try {
    const body = await request.text();
    const params = JSON.parse(body);

    return new Response(responseData, {
      headers: {
        "content-type": "application/json;charset=UTF-8",
      status: 200
  catch(err) {
    return new Response(err, { status: 500 });

The problems that I have run into might seem trivial or like something that I should know, but my point is this: No one complains about having documentation that is too thorough or that explains too much. For example, explain that your platform uses the Fetch API and what that means for the programmer. Don’t assume that they know that your platform uses fetch or that they know what they have to do to get everything working with fetch (e.g. you have to configure faunadb to use fetch instead of XMLHttpRequest). I have very little experience using fetch, so I would benefit from a little guidance.

In your documentation, please don’t assume that people know how to do things on your platform because it is very, very frustrating to try to get up to speed on a new platform. When writing your getting started guides, assume that your audience is coming from Express.js and that they have no idea what serverless platforms are. Or assume that your audience is coming from frontend development. Whatever you do please don’t assume that people know how to use your platform.

Thank you.

This topic was automatically closed after 31 days. New replies are no longer allowed.