Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multivendor] Maximum call stack size exceeded upon setting shipping method #3355

Open
twlite opened this issue Feb 9, 2025 · 4 comments
Open
Labels
type: bug 🐛 Something isn't working

Comments

@twlite
Copy link
Contributor

twlite commented Feb 9, 2025

Describe the bug
Sometimes vendure throws call stack overflow error when setting a shipping method on multivendor plugin. The error seems to occur at

await this.entityHydrator.hydrate(ctx, shippingLine, { relations: ['shippingMethod.channels'] });
where the mergeDeep function invoked by EntityHydrator goes too deep.

To Reproduce
Steps to reproduce the behavior:
The issue does not occur 100% of the time. But when it does, it happens after setting shipping method on an order.

Expected behavior
It should not cause stack overflow error.

Environment (please complete the following information):

  • @vendure/core version: 3.1.2
  • Nodejs version: 22.12.0
  • Database (mysql/postgres etc): postgres

Additional context
This issue started appearing out of the blue. The related discord thread is #1336949445153263667

@twlite twlite added the type: bug 🐛 Something isn't working label Feb 9, 2025
@michaelbromley michaelbromley moved this to 📦 Backlog in Vendure OS Roadmap Feb 10, 2025
@dylviz
Copy link
Contributor

dylviz commented Feb 13, 2025

We ran into this issue recently as well in multiple places. Our fix at the moment is to break up loading the Channels relation in a separate call. Not the most optimal in my opinion.

@twlite
Copy link
Contributor Author

twlite commented Feb 13, 2025

We ran into this issue recently as well in multiple places. Our fix at the moment is to break up loading the Channels relation in a separate call. Not the most optimal in my opinion.

yes, at the moment that's what I'm doing

@michaelbromley
Copy link
Member

@dylviz for you did it happen consistently? The original issue mentions it only happens sometimes.

If we can isolate some consistently reproducible example code, it will make resolving much faster, plus we can also create a test for it to prevent any future regressions once fixed.

@dylviz
Copy link
Contributor

dylviz commented Feb 13, 2025

@dylviz for you did it happen consistently? The original issue mentions it only happens sometimes.

If we can isolate some consistently reproducible example code, it will make resolving much faster, plus we can also create a test for it to prevent any future regressions once fixed.

From the frontend, I can get this consistently, but I'm not clear what's happening in the backend that is causing this. I can share a few findings as I go through it.

Right now, I'm thinking the issue is here:

isTreeEntityMetadata(currentMetadata) || sourceMetadataIsTree || parentMetadataIsTree;

When the processRelation method is called with the currentPath as "ShippingMethod.Channels", then currentMetaDataisTree returns false. It also returns false when currentPath is "ShippingMethod":

Image

CurrentMetaData:

tableMetadataArgs =
{target: ƒ, name: undefined, type: 'regular', orderBy: undefined, engine: undefined, …}
tableName =
'shipping_line'
tableNameWithoutPrefix =
'shipping_line'
tablePath =
'public.shipping_line'
tableType =
'regular'
target =
class ShippingLine
targetName =
'ShippingLine'
treeChildrenRelation =
undefined
treeLevelColumn =
undefined
treeOptions =
undefined
treeParentRelation =
undefined
treeType =
undefined
uniques =
(0) []
updateDateColumn =
ColumnMetadata {@instanceof: Symbol(ColumnMetadata), length: '', isPrimary: false, isGenerated: false, isNullable: false, …}
versionColumn =
undefined
withoutRowid =
false
[[Prototype]] =
Object

Is anything here a potential red flag? I might be stuck here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: 📦 Backlog
Development

No branches or pull requests

3 participants