Skip to content

@angular/ssr - node drain breaks serverless #29801

Closed

Description

@dklmuc

Command

other

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

19.1.3

Description

When updating to angular 19.2.2 we see a regression while running SSR inside an AWS lambda. Local tests with a 3rd party lib lambda-local shows that response was created by angularNodeAppEngine, but writeResponseToNodeResponse does not seem to resolve anymore as before and lambda process will result in a timeout.

Minimal Reproduction

Reverting locally the changes of #29491 made it work again.

Further debugging:
f (!canContinue) { console.log('destination.write()', canContinue); await new Promise((resolve) => destination.once('drain', resolve)); }
strangely shows canContinue as undefined.

If needed a repro could be provided.

Exception or Error


Your Environment

Angular CLI: 19.2.1
Node: 22.14.0
Package Manager: npm 10.9.2
OS: linux x64

Angular: 19.2.1
... cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.1
@angular-devkit/build-angular   19.2.1
@angular-devkit/core            19.2.1
@angular-devkit/schematics      19.2.1
@schematics/angular             19.2.1
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

Activity

  1. alan-agius4 commented on Mar 11, 2025

    @alan-agius4
    Collaborator

    Hi @dklmuc, it would be great to have a reproduction. However, OutgoingMessage .write should never return undefined.

  2. dklmuc commented on Mar 11, 2025

    @dklmuc
    Author

    @alan-agius4 yes, this is also what is confusing me after reading the node docs for .write

    I've added a small repro: https://github.com/dklmuc/angular-srr-lambda

    • npm ci
    • npm run build
    • lambda-local -l lambda.js -e event_origin_request.json

    This will output the angular response to console and then it runs into the default timeout of 3 seconds.

    Sidenodes:
    I've added also a console log when writeResponseToNodeResponse resolves which is not coming, so this is why I think somehow the added promise in the pull request is now stuck due to the undefined and maybe that drain event is not fired.

    I can't rule out if it is an error in the used serverless package translating the lambda event into a request object, but like I've said removing that change from the pull request locally is solving this problem.

  3. alan-agius4 commented on Mar 11, 2025

    @alan-agius4
    Collaborator

    Indeed, it does seem like a bug in the mentioned package. In fact there has been a long standing issue CodeGenieApp/serverless-express#683

    For the time being we could potentially do a workaround.

  4. added a commit that references this issue on Mar 11, 2025
    df1a33a
  5. added
    freq1: low
    on Mar 11, 2025
  6. added theissue type on Mar 11, 2025
  7. dklmuc commented on Mar 11, 2025

    @dklmuc
    Author

    @alan-agius4 thanks a lot for the quick help.

  8. added a commit that references this issue on Mar 11, 2025
    e6e8ce9
  9. added a commit that references this issue on Mar 11, 2025
    ee8466d
  10. angular-automatic-lock-bot commented on Apr 11, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  11. locked and limited conversation to collaborators on Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular/ssrfreq1: lowseverity5: regressiontype: bug/fix

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions