You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
JIT invoices for item creation currently fail on c267bf9 because serializeInvoiceable returns an empty array if a JIT invoice was used (hash provided).
Steps to Reproduce
Post something without enough sats
Pay invoice
HODL invoice gets settled because we immediately settle it after the db transaction.
However, the action still fails because of an TypeError:
Field Mutation.upsertComment failed with TypeError: Cannot read properties of undefined (reading 'text')
Expected behavior
JIT invoices work for posting content + HODL invoices don't get settled if action fails
Video
video2024-01-10.23-22-58.mp4
Additional context
Bug is triggered by results = results.slice(1,-1) since results only contains two elements (see video) and thus the end index of -1 points to the same start index of 1:
$ node
Welcome to Node.js v21.4.0.
Type ".help" for more information.
> let x = [1,2]
undefined
> x.slice(1,-1)
[]
> let y = [1,2,3]
undefined
> y.slice(1,-1)
[ 2 ]
I wonder if we can simply use results[1] instead of results.slice(1,-1). But not sure yet, don't want to break anything else. Okay, I guess the intention with this code was to simply remove the first element and don't care about the size of the array. So results[1] isn't the same. But something like results.length > 2 ? results.slice(1,-1) : [results[1]] would be. (jeez, is this ugly code but I started with this mess, lol)
I also wonder where the 1 as the first element of the returned array of serialize comes from (see video). confirm_invoice returns 0, not 1.
The text was updated successfully, but these errors were encountered:
Description
JIT invoices for item creation currently fail on c267bf9 because
serializeInvoiceable
returns an empty array if a JIT invoice was used (hash
provided).Steps to Reproduce
HODL invoice gets settled because we immediately settle it after the db transaction.
However, the action still fails because of an
TypeError
:Expected behavior
JIT invoices work for posting content + HODL invoices don't get settled if action fails
Video
video
2024-01-10.23-22-58.mp4
Additional context
Bug is triggered by
results = results.slice(1,-1)
sinceresults
only contains two elements (see video) and thus the end index of-1
points to the same start index of1
:stacker.news/api/resolvers/serial.js
Lines 85 to 91 in c267bf9
I wonder if we can simply useOkay, I guess the intention with this code was to simply remove the first element and don't care about the size of the array. Soresults[1]
instead ofresults.slice(1,-1)
. But not sure yet, don't want to break anything else.results[1]
isn't the same. But something likeresults.length > 2 ? results.slice(1,-1) : [results[1]]
would be. (jeez, is this ugly code but I started with this mess, lol)I also wonder where the
1
as the first element of the returned array ofserialize
comes from (see video).confirm_invoice
returns 0, not 1.The text was updated successfully, but these errors were encountered: