From 6c88ebfd4b8e7d3d976cf3fd66c496394f845e87 Mon Sep 17 00:00:00 2001
From: Sasha Sorokin <10401817+Brawaru@users.noreply.github.com>
Date: Wed, 13 Oct 2021 10:02:55 +0700
Subject: [PATCH] fix(streaming): req.scopes can be nullable (#16823)

When checking for required OAuth scopes, an unexpected error could
happen due to missing (null-y) req.scopes. This commit fixes that by
checking if req.scopes are present before checking if any required
scopes are present, otherwise it skips that straight to rejection.
---
 streaming/index.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/streaming/index.js b/streaming/index.js
index 67cd48b43e..8b7477a44c 100644
--- a/streaming/index.js
+++ b/streaming/index.js
@@ -430,7 +430,7 @@ const startWorker = (workerId) => {
       requiredScopes.push('read:statuses');
     }
 
-    if (requiredScopes.some(requiredScope => req.scopes.includes(requiredScope))) {
+    if (req.scopes && requiredScopes.some(requiredScope => req.scopes.includes(requiredScope))) {
       resolve();
       return;
     }