It is in Sefer Chasidim 655:
מעשה בבן שכבד את אביו ביותר. א"ל האב אתה מכבדני בחיי תכבדני במותי. אני מצוך שתלין כעסך לילה אחד ועצור רוחך שלא תדבר לאחר פטירת אביו הלך לו למדינת הים והניח אשתו מעוברת והוא לא ידע. ועכב בדרך ימים ושנים וכשחזר בעיר בא בלילה ועלה לחדר שאשתו היתה שם שוכבת ושמע קולו של בחור שהיה מנשק אותה שלף חרבו ורצה להרוג שניהם. וזכר מצות אביו והשיב' לתערה. שמע שאמרה לאותו בחור בנה שאצלה כבר יש שנים רבות שהלך אביך מאצלי. אילו היה יודע שנולד לו בן כבר הגיע להשיא לך אשה. כששמע זה הדבר אמר פתחי לי אחותי רעיתי. ברוך ה' שעצר כעסי וברוך אבי שציוני לעצור כעסי לילה אחת שלא הרגתי אותך ואת בני. ושמחו שמחה גדולה ועשו משתה לכל העם הנמצאים ושמחו הרבה מאד.
Artscroll's Igeres HaRamban (p.34) loosely translates
Once there was a son who was extraordinarily respectful to his father.
On his deathbed, the father said "My son, you honored me in my
lifetime and now you must honor me after my death. I command you - if
you should ever be overcome by anger, hold your anger in overnight."
After his father's death, the son was forced to embark on a prolonged
journey which took him to distant lands for tens of years. Unbeknownst
to him, the wife he left behind was expecting his child. After his
years of absence, the husband returned home unannounced, hoping to
joyously surprise his wife. But as he approached his bed-chamber he
saw his wife embracing a handsome young man, a stranger. The husband
became fiercely jealous and reached for his dagger - when he suddenly
remembered the pledge he made to his father: He must hold in his rage
overnight. The next day he was shocked to discover that the young man
in his wife's embrace was none other than his own son, the child that
his wife had borne during his long absence. The man was thus saved
from tragically slaughtering his own family.