Serverless-offline: CORS preflight requests ignored, HTTP request left hanging forever

Created on 31 Dec 2020  路  2Comments  路  Source: dherault/serverless-offline

Bug Report

I just migrated from sls offline 3.31.3 (sls 1.36.1) to sls offline 6.8.0 (sls 2.17.0) and all my preflight (OPTIONS) requests are left hanging. Trying to investigate I ended up in the HAPI library in the _lifecycle method, where this._route._cycle has 2 functions, 1st one being internal.drain which ends up setting the _eventContext.request to null here, thus ignoring the 2nd function in the _route._cycle here. If I remove the 1st function manually from the _route._cycle everything works fine.

GET works correctly on the resources.

Sample Code

  • file: serverless.yml
...
functions:

  findTags:
    handler: src/.../handler/path/...
    events:
      - http:
          method: GET
          path: tags
          cors: true
...

Environment

  • serverless version: 2.17.0
  • serverless-offline version: 6.8.0
  • node.js version: v15.5.0
  • OS: Ubuntu 20.04.1 LTS

Most helpful comment

Downgrading Node to v14.15.3 fixed the problem.

All 2 comments

Downgrading Node to v14.15.3 fixed the problem.

It was a bug in 15.5.0. The change was reverted as part of 15.6.0, so you can use 15.4.0 or 15.6.0 too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stonebraker picture stonebraker  路  3Comments

ozbillwang picture ozbillwang  路  4Comments

stunningpixels picture stunningpixels  路  3Comments

dnalborczyk picture dnalborczyk  路  3Comments

Ali-Dalal picture Ali-Dalal  路  4Comments