diff --git a/index.js b/index.js
index <HASH>..<HASH> 100644
--- a/index.js
+++ b/index.js
@@ -76,6 +76,7 @@ function attachVirtuals(schema, res) {
 
 function attachVirtualsToDoc(schema, doc, virtuals) {
   const numVirtuals = virtuals.length;
+  if (doc == null) return;
   if (Array.isArray(doc)) {
     for (let i = 0; i < doc.length; ++i) {
       attachVirtualsToDoc(schema, doc[i], virtuals);
fix: avoid undefined doc from being virtualized