stacks.js: Fix coreNode error when fetching public data with no user session

As first encountered with https://github.com/markmhx/humans/issues/12, I’m getting TypeError: Cannot read property 'coreNode' of undefined upon calling getFile and reaching: https://github.com/blockstack/blockstack.js/blob/950dc4fc838099835ce0592f245453c770663b84/src/storage/index.ts#L253

sessionData.userData is undefined and throws an error instead of getting to use caller.appConfig.coreNode

cc @zone117x since he appears to be the last person to touch this part of the code

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

It looks like changing this line https://github.com/blockstack/stacks.js/blob/7915c953d4b7c6a2d8e7a2f3125c449687ff8aac/packages/storage/src/storage.ts#L867 To

 const configuredCoreNode = sessionData.userData?.coreNode || userSession.appConfig.coreNode;

should at least fix the error being thrown that Mark first mentioned.

@marcosc90 is this something you could take on?

@markmhx my bad, didn’t mean to close this

@aulneau mind adding your workaround here in the meantime for reference?

The code snippet I provided is not actually a workaround for this specific issue.

I think this was never prioritized and we got started on the monorepo work in the meantime. @yknl could you take a look, please? maybe we could include this in the monorepo release?

This breaks the todo-list tutorial to lookup public lists for new users. https://docs.blockstack.org/authentication/building-todo-app#sign-out-and-see-your-public-tasks

Hmm, @markmhx can you provide a repo/snippet of code to easily reproduce? Looks like this is an easy fix but not entirely sure what the intention behind this code