Skip to content

Angular async/await handling makes LangChainJS fail #26204

Closed as not planned
Closed as not planned
@gsans

Description

@gsans

Which @angular/* package(s) are the source of the bug?

compiler-cli, zone.js

Is this a regression?

No

Description

While trying the getting started code for LangChainJS I’ve noticed that async/await code in base.js fails to work. It’s supposed to wait for a request to comeback but it fails immediately as it doesn’t wait.

Zones and a Generator wrapper seems to be involved. It’s not clear if it’s Angular fault or LangChainJS built or both. A babel plugin that is used to wrap promises into generators could also be involved.

Without a fix LangChainJS the most popular library for GenerativeAI is unusable with Angular. It seems that OpenAI library may cause similar issues.

In order to reproduce you need an OpenAI api key.

More details available in this issue at LangChainJS
langchain-ai/langchainjs#3105 (comment)

Please provide a link to a minimal reproduction of the bug

langchain-ai/langchainjs#3105 (comment)

Please provide the exception or error you saw

ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'message')
TypeError: Cannot read properties of undefined (reading 'message')
    at base.cjs:233:34
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (asyncToGenerator.js:3:1)
    at _next (asyncToGenerator.js:22:1)
    at _ZoneDelegate.invoke (zone.js:368:26)
    at Object.onInvoke (core.mjs:11083:33)
    at _ZoneDelegate.invoke (zone.js:367:52)
    at Zone.run (zone.js:129:43)
    at zone.js:1257:36
    at _ZoneDelegate.invokeTask (zone.js:402:31)
    at resolvePromise (zone.js:1193:31)
    at zone.js:1100:17
    at zone.js:1116:33
    at asyncGeneratorStep (asyncToGenerator.js:6:1)
    at _throw (asyncToGenerator.js:25:1)
    at _ZoneDelegate.invoke (zone.js:368:26)
    at Object.onInvoke (core.mjs:11083:33)
    at _ZoneDelegate.invoke (zone.js:367:52)
    at Zone.run (zone.js:129:43)
    at zone.js:1257:36

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: investigationRequires some digging to determine if action is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions