object is not iterable (cannot read property Symbol(Symbol.iterator))
u.searchParams & h.searchParams may be null and causes a TypeError -- and noisy error in Sentry
File: commerce-sdk-isomorphic/lib/index.esm.js
Source functions: loginGuestUser: function (e, t) {return vI.apply(this, arguments);}, loginRegisteredUserB2C: function (e, t, r) {return mI.apply(this, arguments);},
Line with error: if (((d = e.sent), (c = (null === (i = d.headers) || void 0 === i ? void 0 : i.get("location")) || d.url), (u = new URL(c)), (l = Object.fromEntries(u.searchParams.entries())), !(d.status >= 400 || l.error))) {
Line with error: if (((u = e.sent), (l = (null === (i = u.headers) || void 0 === i ? void 0 : i.get("location")) || u.url), (h = new URL(l)), (f = Object.fromEntries(h.searchParams.entries())), !(u.status >= 400 || f.error))) {
Suggested change: u.searchParams.entries to u.searchParams?.entries ?? {} and same for h.searchParams
Hey @janderson-watchbox, thanks for creating this issue. Wanted to check something, have you confirmed that u.searchParams.entries() is null or is it an object? Asking as I tested passing around different inputs to Object.fromEntries() and this is what I found:
Object.fromEntries(undefined)
VM418:1 Uncaught TypeError: undefined is not iterable
at Function.fromEntries (<anonymous>)
at <anonymous>:1:8
Object.fromEntries(null)
VM433:1 Uncaught TypeError: undefined is not iterable
at Function.fromEntries (<anonymous>)
at <anonymous>:1:8
Object.fromEntries({})
VM448:1 Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
at Function.fromEntries (<anonymous>)
at <anonymous>:1:8
Seems like an object is getting passed to the function Object.fromEntries() which is also unexpected, I'll create a ticket in the backlog to investigate
This issue has been linked to a new work item: W-17766483