How to get all pending transactions using web3js

I am working on custom blockchain testnet.
I wanna see all pending transactions on my local block explorer.
To do this I first tried with web3.eth.getPendingTransactions() but it always returned empty array even though there is a pending transaction.
So I tried with web3.eth.subscribe with pendingTransaction parameter.

const Web3 = require("web3");
const web3 = new Web3("ws://");
var pndTxns = [];

      .subscribe("pendingTransactions", function (error, result) {
        if (!error) console.log(result);
      .on("data", function (transaction) {


It actually worked in web3.eth.subscription block, but outside of that pndTxns logs empty array.
I tried to find answer for several days but not found yet.
So how can I get all pending transactions at the moment at once?
Any help will be really appreciated.

Hi there. Welcome to Infura community @Ermoshin.
How are you calling for the pendingTransactions outside of the subscription? Can you help to share the snippet of code as well?
How to get pending transactions using Infura? this thread could be a useful resource for you.