Check for undefined Value When Deleting Pages #1902
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey there!
I wanted to use
gatsby-plugin-sitemap
but wanted allloc
s without trailing slashes (our webserver is configured this way as well). I followed your example here to remove trailing slashes in allpath
s, but unfortunately the build fails with:This is because
emitter
listens to theDELETE_PAGE
action being triggered here and then callingdeleteNode(createPageId(action.payload.path))
(note that one param is passed).deleteNode
accepts two arguments;nodeId
andnode
(plusplugin
with a default value). Both values,nodeId
andnode
are passed as the action's payload.Here the
emitter
listens toDELETE_PAGE
actions, and pushesaction.node
into thequeuedDirtyActions
array - in my caseaction.node
isundefined
.Later, the pager query runner tries to find dirty IDs here by reading
queudDirtyActions
-node
is stillundefined
and therefore readingnode.id
on L112 results in an error.I'm not convinced that this is the best solution, but honestly, I don't understand the process well enough to decide this. Maybe it makes more sense to pass the node, but I wouldn't know how to find and get the correct one. Or even checking in
deleteNode
whethernode
is defined, and only passing it then - the same were theemitter
is listening for theDELETE_NODE
action.I hope this all made sense to you! Let me know what you think.
Cheers,
Rob