Serverless error trying to deploy cloudflare worker

Hi,

I’m following the steps given in the serverless cloudflare workers guide, and have cobbled together my serverless.yml & javascript function:

service:
    name: example-watcher
    config:
      accountId: 1234
      zoneId: abcd
      workers:
        example-watcher-fn:
          routes:
            - foo.com/example-requests/*

provider:
  name: cloudflare

plugins:
  - serverless-cloudflare-workers

functions:
  exampleWatcherFunction:
    worker: example-watcher-fn
    script: dist/main  # webpacked away into ./dist/main.js ...
    events:
      - http:
          url: foo.com/example-requests/response
          method: GET
          headers:
            foo: bar
            x-client-data: value

On running serverless deploy I get this error, seemingly bubbling up from the serverless-cloudflare-workers plugin:

  Serverless Error ---------------------------------------
 
  Serverless plugin "serverless-cloudflare-workers" initialization errored: missing ) after argument list
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information -----------------------------
     OS:                     darwin
     Node Version:           6.14.4
     Serverless Version:     1.32.0

I’ve stripped the javascript worker function down to do essentially nothing, but still the error pops up. Here’s the js file content being used:

addEventListener('fetch', event => {
    event.respondWith(fetch(event.request))
});

Given that I can’t seem to find references of anyone else running into this problem, it’s likely something I’m doing wrong, but can’t see much detail around the problem, so not sure where to start here.

Has anyone else bumped into this before?

Thanks,
Chris.

Ok, looks like I’ve got the answer, thanks to staff at cloudflare pointing it out to me. Just closing it off here for anyone else that hits this.

Looks like if I use a newer version of node (eg. v10.x), serverless deploy runs here without seeing this explosion from the serverless-cloudflare-workers plugin.

I guess the required node version, over here on the quickstart guide might need to be bumped up a bit.

Cheers!

1 Like

Thank you for this!!

Was getting the same error with Node version 6.17.1. Using v10.x fixed it.

Cheers!

Will be updating that requirement. Appreciate your input to make our docs better. Thanks!!