In History, 1838–1856, volume F-1 [1 May 1844–8 August 1844]: 147 we read the following under the date of June 22, 1844:
I told Stephen Markham that if I
and Hyrum were ever taken again, we should be massacred, or I was not a prophet
of God; “I want Hyrum to live to avenge my blood, b<ut> he is determined
not to leave me.”
According to Dan Vogel, this was
Inserted by L[eo]H[awkins] on
blank line in Book F-1, 147 (History of Joseph Smith and The Church of Jesus
Christ of Latter-Day Saints, ed. Dan Vogel, 8 vols [Salt Lake City: The
Smith-Pettit Foundation, 2015], 634 n. 35)
According to the Joseph Smith Papers website, the source
for this is Stephen Markham's letter to Wilford Woodruff, June 20, 1856, p. 1 (CR 100 396, Church History Library):
. . . that if he & Hyrum were
ever taken again the[y] Would be Massacred or he was not a Prophet of God, he
said he wanted to save Hyrum to avenge his Blood. he said that Hyrum was
determined Not to Leave him but die with him.
Because this report comes 12 years after the fact, it is not a primary source, though Markham was a close associate of Joseph and is relaying his own experience hearing Joseph Smith make this prediction. It is not as "solid" as some LDS apologists believe it to be, though, at the same time, not terribly unreliable or super late.
Be that as it may be, that Joseph Smith could be killed was always
an open possibility. In an early revelation received in March 1829, and initially
published as Section
XXXII:4 (what is now D&C 5:22) of the 1835 Doctrine and Covenants, we read:
And now I command you, my servant
Joseph, to repent and walk more uprightly before me, and yield to the
persuasions of men no more; and that you be firm in keeping the commandments
wherewith I have commanded you, and if you do this, behold I grant unto you
eternal life, even if you should be slain.
In terms of attempts to respond to these predictions, we have the
following from J. P. Holding, The Prophecies of Joseph
Smith: A Critical Look:
Given the Biblical precedence for
the slaying of prophets (1 Kings 19, Matt. 23:31-34, Acts 7:52, Rev. 18:24),
and Smith's prior troubles, this may be prophetic insight -- or just a natural
understanding of his likely fate.
Worst case scenario for the LDS apologists is that we have a contingent prophecy/promise that was fulfilled on June 27, 1844, and a late-ish (12 years) reminiscence from Stephen Markham who heard Joseph Smith make a prediction of his impending death 5 days before the fact.
Further Reading:
Resources on Joseph Smith's Prophecies