Turn on the “Saute” setting on the Instant Pot, and add olive oil and onion to the inner pot. Cook for about 5-6 minutes, stirring occasionally, until onion is softened and translucent. Add garlic, basil, red pepper flakes and continue to saute for 30 seconds or until you begin to smell the spices.
Add the chicken stock to the pot, and scrape any bits stuck to the bottom of the pot. Break the spaghetti in half, and add to the pot, spiraling the pasta around the pot.
Without stirring, add marinara or spaghetti sauce on top of the pasta. (Not stirring in the tomato sauce will prevent receiving the “Burn” notice on the Instant Pot.)
Close the instant pot with the lid, and turn the steam valve to “Sealing”. On the Instant Pot, click “Cancel” (or equivalent) to stop “Saute”. Click the “Manual” button on High Pressure. Set the timer for 8 minutes* and allow the Instant Pot to come to pressure (about 10-15 minutes).
Once the cooking time is finished, turn the steam valve to “Venting” to release the pressure manually. Be sure to do this right as it finishes cooking to prevent overcooked pasta.
Add the heavy cream to the pasta, and season to taste with salt and pepper.