Discord Bot doesn’t behave same in different servers

I have made a Discord bot using javascript (I’m very new to js) and once I add it to two different discord servers, even though it has the same permissions, it doesn’t work the same way.
The bot should post a message every monday at 9am to a specific channel named “design-challenges”. In one server it does exactly that, in the other server it doesn’t. The bot is online in both servers and I can see it runs basic commands like !hello fine in both.

Here’s my code, if that helps:

const { Client, GatewayIntentBits } = require('discord.js');
const fs = require('fs').promises;
const cron = require('node-cron');

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMembers,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
  ],
});

const prefix = '!';
const challengeChannelName = 'design-challenges';
let challenges;

// Store the current challenge index
let currentChallengeIndex = 1;

client.on('ready', async () => {
  console.log(`Logged in as ${client.user.tag}`);
  challenges = await loadChallenges();
  scheduleWeeklyChallenge();
});

client.on('messageCreate', (message) => {
    // Ignore messages from bots
    if (message.author.bot) return;
  
    // Check if the message starts with the command prefix
    if (message.content.startsWith(prefix)) {
      const [command, ...args] = message.content.slice(prefix.length).split(' ');
  
      if (command === 'ping') {
        message.channel.send('Pong!');
      } else if (command === 'hello') {
        message.channel.send('Hello!');
      }
      if(command === 'challenge') {
        const challenge = getNextChallenge();
        message.channel.send(challenge);
      }
    }
  });
  

function scheduleWeeklyChallenge() {
  // Set a cron job to send a challenge every Monday at 9:00 AM
  cron.schedule('0 8 * * 1', () => {
    const channel = client.channels.cache.find(ch => ch.name === challengeChannelName);

    if (channel) {
      const introText = `
@everyone
# Er du klar til at udfordre dine designfærdigheder?
Vi inviterer dig til at deltage i vores seneste udfordring og give dine medstuderende feedback.nHusk at upload din challenge lige herunder, ikke som reply.

Denne uges challenge er:`;
      const challenge = getNextChallenge();

      // Send introductory message
      channel.send(introText)
        .then(() => {
          // Wait for a moment (you can adjust the timeout duration) before sending the challenge
          return new Promise(resolve => setTimeout(resolve, 2000));
        })
        .then(() => {
          // Send the challenge
          channel.send(challenge);
        })
        .catch(error => console.error('Error sending challenge:', error));
    }
  });
}

async function loadChallenges() {
  try {
    const data = await fs.readFile('challenges.json');
    return JSON.parse(data);
  } catch (error) {
    console.error('Error loading challenges:', error);
    return [];
  }
}

function getNextChallenge() {
  const currentIndex = currentChallengeIndex;
  const nextChallenge = challenges[currentIndex];

  // Increment the challenge index for the next time
  currentChallengeIndex = (currentIndex + 1) % challenges.length;

  return `## ${currentIndex + 1}: ${nextChallenge.title}
* **What**: ${nextChallenge.what}
* **Target**: ${nextChallenge.target}
`;
}

client.on('messageCreate', async (message) => {
  if (message.channel.name === 'design-challenges' && message.attachments.size > 0) {
      const thread = await message.channel.threads.create({
          name: `feedback-${message.author.displayName}`,
      });

      await thread.send(`${message.author} har indgivet et bidrag. Giv jeres konstruktive feedback herunder.`);
      await thread.send(`Oprindelig fil: ${message.attachments.first().url}`);
  }
});

client.login(process.env.TOKEN);

I don’t understand why it works in one server but it doesn’t work in the other. Please help

Convert SVG To PDF Retaining “embedded” images

I’m looking for a way to convert an SVG to PDF in Javascript that works with tags in the SVG. So far the SVG to PDF solutions I’ve tried just show a blank image where the should be. This includes SVG-to-PDFKit: https://github.com/alafr/SVG-to-PDFKit#readme

I’ve tried with a link as the href value, and base64 encoding. I’ve tried free online SVG to PDF converters as well, all of which generated a blank image. The other shapes and paths in the file remained correct, it’s just elements giving me trouble.

Reset JavaScript variables [closed]

I have a dashboard, sidebar and section for content. In the sidebar, I have the pages and I load the pages using content.innerHtml(page) however the page has variables like let variable1=3,varaible2=5 and when I load the second page these variables still is there a way to limit the scope of these variables or reset them where even if clicked on the same page it gives it is already declared I can use var but it isn’t the optimal solution.I am using spring boot and Thymeleaf.

how do i use proxy with electron-fetch?

I am using electron-fetch npm and I want to use a proxy with it. I tried the proxy option which works in request npm yet it seems to not work.

this is my code block, yet i see my ip always the same(proxy not used). for demonstration i put the proxy ip as 1.1.1.1

my proxy doesn’t have any authentication so i don’t have to use user or password options like it shows in the link, yet if somebody gives an answer it’d also be nice to see an example of that.


  const fetch = require('electron-fetch').default

  fetch("https://api.ipify.org/?format=text" , {proxy  : 'http://1.1.1.1'})
        .then(res => res.text())
    .then(body => console.log(body))

this doesn’t connect to the proxy

Javascript: browser.browserAction.onClicked.addListener is detached from debug

I stumbled upon a very strange error:

Uncaught (in promise) Error: An unexpected error occurred

and what makes this strange is the undefined:460:13 reference I’m getting, this line is the closing brace } of my:

browser.runtime.onMessage.addListener((message, sender, sendResponse) => {

something inside here is triggering this error, I checked every closing brace, every Promise has its .then() and .catch() the error is visible inthe debugger, but not because it is being catched, the code continue to work properly. It has been days I’m trying to fix this, and the undefined part is not helping.

This is the full stack trace:

Uncaught (in promise) Error: An unexpected error occurred
    RegisterContextMenu moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:460
    promise callback*RegisterContextMenu moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:459
    SetPassword moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:656
    promise callback*SetPassword/< moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:648
    SetPassword moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:642
    RegisterListeners moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:355

    apply self-hosted:2337
    applySafeWithoutClone resource://gre/modules/ExtensionCommon.sys.mjs:640
    wrapPromise resource://gre/modules/ExtensionCommon.sys.mjs:968
    enter resource://devtools/server/actors/utils/event-loop.js:82
    _pauseAndRespond resource://devtools/server/actors/thread.js:968
    hit resource://devtools/server/actors/breakpoint.js:220
    RegisterContextMenu moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:460
    (Asinc.: promise callback)
    RegisterContextMenu moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:459
    SetPassword moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:656
    (Asinc.: promise callback)
    SetPassword moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:648
    SetPassword moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:642
    RegisterListeners moz-extension://96baacab-87a8-4be3-b8f8-74292ccebe98/background.js:355
    apply self-hosted:2337
    raw resource://gre/modules/ExtensionCommon.sys.mjs:2783
    wrapResponse resource://gre/modules/ExtensionChild.sys.mjs:206
    responses resource://gre/modules/ExtensionChild.sys.mjs:175
    map self-hosted:221
    emit resource://gre/modules/ExtensionChild.sys.mjs:175
    recvRuntimeMessage resource://gre/modules/ExtensionChild.sys.mjs:375
    _recv resource://gre/modules/ConduitsChild.sys.mjs:77
    receiveMessage resource://gre/modules/ConduitsChild.sys.mjs:189

I have a switch handling the browser.runtime.onMessage.addListener one of the switches allow the user to set a password to save its data, and it is invoked by the settings page so defined in the manifest.json file:

  "options_ui": {
    "page": "settings/settings.html"
  },    

The other option allow the user to enter user/password and lookup the data phoning home, then automatically add the same password, using the same routine. In short both are doing the same thing at the end of the day, the passwords used are the same for the purpose of this test, so I donnt get what could go so wrong.

These are the cases of the switch the set-password is the one giving this problem, prevening the browser.runtime.onMessage.addListener to being correctly considered, I cannot even stop it with breakpoints, the debugger looks totally detatched:

        case "set-password":
            var password = message.password;

            // Call the wrapper function and handle the promise
            SetPassword(password)
                .then((result) => {
                    // Processing is done, call sendResponse with the result
                    sendResponse({ isValid: true });   
                })
                .catch((error) => {
                    // Handle errors if needed
                    console.error(error);
                });                       
            return true;                              
            break;
        case "login-step2":
            var credentials = message.credentials;

            SetupLogin2fa(credentials)
                .then((data) => {
                    if (data.isValid){
                        workstationData.activated=true;
                        workstationData.serial=data.serial;
                        workstationData.privatekey=data.privatekey;

                        // Call the wrapper function and handle the promise
                        SetPassword(credentials.password)
                            .then((result) => {                                
                                // Processing is done, call sendResponse with the result
                                sendResponse({ isValid: true });     
                            })
                            .catch((error) => {
                                // Handle errors if needed
                                console.error(error);
                            });   

                    } else {
                        sendResponse({ isValid: false });    
                    }               
                })
                .catch((error) => {
                    console.log(error);
                });

            return true;                       
            break;      

And this is the SetPssword function, agan it is working fine, but there must be something somewhere, something… undefined that I cannot catch:

function SetPassword(password) {
    return new Promise((resolve, reject) => {
        SNIPCrypto.encryptTextWithAES(workstationData.serial, password)
            .then((encryptedSerial) => {
                workstationData.serial = encryptedSerial;
                return SNIPCrypto.encryptTextWithAES(workstationData.privatekey, password);
            })
            .then((encryptedPrivatekey) => {
                workstationData.privatekey = encryptedPrivatekey;
                workstationData.password = true;
                workstationData.unlocked = false;

                //browser.storage.local.set({'config': JSON.stringify(workstationData)});
                SaveWorkstationData();

                RegisterContextMenu();

                resolve({});
            })
            .catch((error) => {
                reject(error);
            });
    });
}

I’m short on ideas about what else to check, the project is a lot bigger than this, however this is the patch from setting the password, the only remaining relevant bit is the settings page and its javascript allowing the user to pick a password, again I enter the same password in both cases, it is not the password used:

document.getElementById('setPassword').addEventListener('click', function() {

    var password = document.getElementById('txtPassword').value;
    var passwordConfirm = document.getElementById('txtPasswordConfirm').value;

    //clear eventual error from the last attempt
    document.getElementById('error').setAttribute("hidden", "");     

    if (password.length >= 8){
        if (password == passwordConfirm){

            browser.runtime.sendMessage({ action: "set-password", password:password }, response => {                
               if (response.isValid){            
                    document.getElementById('panel-password').setAttribute("hidden", "");
                    document.getElementById('panel-confirm').removeAttribute("hidden");
                } else {                    
                    document.getElementById('error').innerText ="* passwords doesn't match *"
                    document.getElementById('error').removeAttribute("hidden");                       
                }

            });

        } else {
            document.getElementById('error').innerText ="* passwords doesn't match *"
            document.getElementById('error').removeAttribute("hidden");
        }
    } else {
        document.getElementById('error').innerText ="* password must be at least 8 character *"
        document.getElementById('error').removeAttribute("hidden");
    }

});

How make a tampermonkey script that makes left click this mouse presing x key?

Hello Stack Overflow community,

I am looking for assistance in creating a Tampermonkey script that simulates mouse clicks when specific keys are pressed. Here is what I need:

When I press the “X” key, the script should simulate a left mouse click.
Additionally, I would like the ability to customize the script so that pressing other keys, like “R,” triggers a mouse click and press key 2 (the number of the keyboard).

How to get container to grow along with divs?

Hey guys im trying to build an etch-a-sketch, having issues making my divs stay inside its container. I also would like the container to stretch if I were to add more divs.My divs are made via a function.

!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" href="styles.css" />
    <script text='text/javascript' src="Etch.js" defer></script>
    <title>Etch-a-Sketch</title>
  </head>
  <body>
    <div id="container"></div>
  </body>
</html>

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: 1px solid red;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#container {
  width: 700px;
  height: 700px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.squares {
  height: 40px;
  width: 40px;
  padding: 10px;
  flex-grow:1;
}

React `flushSync` and `createRoot` works and not works

I have the following piece of code which should synchrounously render some react node inside dom NODE.

    const DOM = (
      <div
        {...attributesToProps(attrs)}
        className={cn(
          'p-[8px]',
          variant === 'theorem' ? 'border-blue-7 bg-blue-3' : '',
          variant === 'definition' ? 'border-violet-7 bg-violet-3' : '',
          variant === 'remark' ? 'border-red-7 bg-red-3' : '',
          variant === 'example' ? 'border-green-7 bg-green-3' : ''
        )}
      >
        <div
          className={cn(
            'absolute left-0 top-0 rounded-full bg-background p-[8px]',
            variant === 'theorem' ? 'text-blue-8' : '',
            variant === 'definition' ? 'text-violet-8' : '',
            variant === 'remark' ? 'text-red-8' : '',
            variant === 'example' ? 'text-green-8' : ''
          )}
          style={{
            transform: 'translate(calc(-50% - 1.5px), -50%)',
          }}
        >
          <MathPanelIcon variant={variant} />
        </div>
        <div className='flex flex-col gap-4'>
          <p className='!m-0 text-2xl font-semibold'>
            <TextGradient color={gradient as GradientColor}>
              {label}
            </TextGradient>
          </p>
          <div
            data-type='mathPanelContent'
            className='flex flex-col gap-4'
          ></div>
        </div>
      </div>
    );

    const container = document.createElement('div');
    const root = createRoot(container);
    flushSync(() => {
      root.render(DOM);
    });

    const dom = container.firstChild as HTMLElement;
    const contentDOM = dom.querySelector(
      '[data-type="mathPanelContent"]'
    ) as HTMLElement;

The problem is that it sometimes works and sometimes not. For example, here is works:
enter image description here

But here not:
enter image description here

Any ideas what differ these two cases?

React-native-background-action Cannot read property ‘start’ of null

i have a problem with repository react-native-background-action.
It showing issue
Type Error, cannot read property ‘start’ of null
Picture is attached
enter image description here

My code exemple

import { View, Button } from 'react-native';
import BackgroundService from 'react-native-background-actions';

const sleep = (time:number) => new Promise<void>((resolve) => setTimeout(() => resolve(), time));

const veryIntensiveTask = async (taskDataArguments:any) => {
    console.log("in intensive task");
    const { delay } = taskDataArguments;
    await new Promise( async (resolve) => {
        for (let i = 0; BackgroundService.isRunning(); i++) {
            console.log(i);
            await sleep(delay);
        }
    });
};

const options = {
    taskName: 'Example',
    taskTitle: 'ExampleTask title',
    taskDesc: 'ExampleTask description',
    taskIcon: {
        name: 'ic_launcher',
        type: 'mipmap',
    },
    color: '#ff00ff',
    parameters: {
        delay: 1000,
    },
};

export default function Background(){
const startBackgoundJob=async ()=>{
    await BackgroundService.start(veryIntensiveTask, options);
    console.log("background service started");
};

const updateBackgroundJob=async ()=>{
    await BackgroundService.updateNotification({taskDesc: 'New ExampleTask description'}); 
    console.log("background service updated");
};
const stopBackgroundJob=async ()=>{
    await BackgroundService.stop();
    console.log("background service stopped");
};
return(
    <View style={{flex:1,display:"flex",justifyContent:"center",alignItems:"center"}}>
        <Button title="start background job" onPress={startBackgoundJob}/>
        <Button title="update background job" onPress={updateBackgroundJob}/>
        <Button title="stop background job" onPress={stopBackgroundJob}/>
    </View>
)
}

The rn-foreground-service showing same issue.

Please let me know if you know how fix it.

Short about what i need.
I need a function what will get the data like current time when the application is inactive or closed.

The code what i am past there, it is a just example.

If you know any repository can help me with it please let me know

Implementing Mulitple mutations to two different API’s using React query

const first = useMutation({
    mutationFn: (data) => {
      return Promise.all([
        (axios.put(
          "https://dummyjson.com/products/1",
          JSON.stringify({
            title: "iPhone Galaxy +1",
          })
        ),
        axios.post(
          "https://reqres.in/api/users",
          JSON.stringify({
            name: "morpheus",
            job: "leader",
          })
        )),
      ]);
    },
    onSuccess: (data) => {
      console.log(data);
    },

    onError: (error) => {
      console.log(error);
    },
  });


actually I want to perform two post requests to two different apis but the useMutation is posting only to the one api

In the above code only the second promise is resolved and the first one not getting resolved


Expected output:
Both promises should be resolved and give the response from both the apis

JQuery add variable to selector [duplicate]

i try to add a variable to the jquery selector to add a css class in leaflet.

var abc = $(TEST._icon);
abc.addClass('pulse');

or

$(TEST._icon).addClass('pulse');

works good. now i want a variable for TEST – so i try following without success:

var abc = "TEST";
$(abc + "._icon").addClass('pulse');

can anybody help?

thank you!

Error Adding Marker Clusters & County Boundaries to Leaflet Map

I am able to add all state boundaries to my leaflet map.
But if I try to add clusters I am getting the below error.

Error in /~/components/MapBoundaries.tsx (138:34)
map is not defined

Can you let me know how to fix it.
Even I tried to California county boundaries after a specific zoom level.
Even that is not working fine.
I debugged and put console.log inside zoom functionalities but sill its not printing console.
Can you let me know how to fix it, providing my code na dfiddle below

import React, { useState, useEffect, useRef } from 'react';
import L from 'leaflet';
import 'leaflet/dist/leaflet.css';
//import geojsonData from './us-states.json';
import CaliforniaCounty from './CaliforniaCounty.json';

import { MapContainer, TileLayer, GeoJSON } from 'react-leaflet';

import statesData from './US-ONLY-States.js';

import 'leaflet.markercluster/dist/MarkerCluster.css';
import 'leaflet.markercluster/dist/MarkerCluster.Default.css';
import * as MarkerCluster from 'leaflet.markercluster';

const MapBoundaries = () => {
  const [geoData, setGeoData] = useState(null);
  const markerClusterGroup = new MarkerCluster.MarkerClusterGroup(); // Here!

  const [countyData, setCountyData] = useState(null); // State for county boundaries

  const mapRef = useRef(); // Add a map reference

  useEffect(() => {
    // Fetch your GeoJSON data
    // fetch('./us-states.json')
    //fetch('path/to/your/data.geojson')
    //  .then(response => response.json())
    //.then(data => setGeoData(data));
    setGeoData(statesData);
    // Create Marker Cluster Group here when map is available
    const markerClusterGroup = new MarkerCluster.MarkerClusterGroup();

    // Add cluster group to map after initial render
    if (mapRef.current) {
      markerClusterGroup.addTo(mapRef.current);
    }

    // Zoom event listener on the map
    if (mapRef.current) {
      mapRef.current.on('zoomend', handleZoomChange);
    }
  }, []);

  const handleZoomChange = () => {
    const currentZoom = mapRef.current.getZoom();

    // Logic to fetch Texas county data if not already loaded and zoom is right
    if (currentZoom >= 8 && !countyData) {
      console.log('if currentZoom', currentZoom);
      // Adjust zoom level '8' as needed
      fetch('./CaliforniaCounty.json')
        .then((response) => response.json())
        .then((data) => setCountyData(data));
    } else if (currentZoom < 8 && countyData) {
      console.log('else if currentZoom', currentZoom);

      // Optionally remove county data when zooming out
      setCountyData(null);
    }
  };

  const getColor = (d) => {
    return d > 1000
      ? '#800026'
      : d > 500
      ? '#BD0026'
      : d > 200
      ? '#E31A1C'
      : d > 100
      ? '#FC4E2A'
      : d > 50
      ? '#FD8D3C'
      : d > 20
      ? '#FEB24C'
      : d > 10
      ? '#FED976'
      : '#FFEDA0';
  };

  const style = (feature) => {
    return {
      fillColor: getColor(feature.properties.dataValue), // Assuming 'dataValue' is your data property
      weight: 2,
      opacity: 1,
      color: 'white',
      dashArray: '3',
      fillOpacity: 0.7,
    };
  };

  // const onEachFeature = (feature, layer) => {
  //   layer.bindPopup(
  //     feature.properties.name + ': ' + feature.properties.dataValue
  //   );
  // };

  const onEachFeature = (feature, layer) => {
    // Create a marker at the feature's location:
    const marker = L.marker(layer.getBounds().getCenter()); // Assuming center of the feature

    marker.bindPopup(
      feature.properties.name + ': ' + feature.properties.dataValue
    );

    layer.bindPopup(
      feature.properties.name + ': ' + feature.properties.dataValue
    );

    markerClusterGroup.addLayer(marker); // Add the marker to the cluster group
  };

  const onEachCountyFeature = (feature, layer) => {
    // Customize how you want to interact with county features here
    layer.bindPopup(`County Name: ${feature.properties.name}`);
  };

  return (
    <MapContainer
      center={[37.09024, -95.712891]}
      zoom={6}
      style={{ height: '500px' }}
      ref={mapRef} // Attach the ref to the MapContainer
    >
      <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
      />
      {geoData && (
        <GeoJSON data={geoData} style={style} onEachFeature={onEachFeature} />
      )}
      {markerClusterGroup.addTo(map)} // Add the cluster group to the map

      {countyData && (
        <GeoJSON
          data={countyData}
          style={{ color: 'black', weight: 1 }} // Basic county boundary styling
          onEachFeature={onEachCountyFeature}
        />
      )}
    </MapContainer>
  );
};

export default MapBoundaries;

Mock AWS SDK calls from a Node module using Jest

In Node, both my code and a module in the node_modules folder use the AWS SDK. When I mock AWS using the aws-sdk-client-mock, my code is correctly mocked when I run my tests, but any calls using the SDK from the module are not mocked. If I copy the code out of the node_modules folder and import it directly, it is mocked correctly. Is there a way to ensure that all calls to the SDK are getting mocked even if called from a module?

Here is a sample of test.js file.

import { mockClient } from "aws-sdk-client-mock";
import {
    SecretsManagerClient,
    GetSecretValueCommand
} from "@aws-sdk/client-secrets-manager";
import {
  RedshiftDataClient,
  ExecuteStatementCommand,
  DescribeStatementCommand,
  GetStatementResultCommand
} from '@aws-sdk/client-redshift-data';
import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs";
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns";

const secretsClient = mockClient(SecretsManagerClient);
const ddbMock = mockClient(RedshiftDataClient);
const SQSMock = mockClient(SQSClient);
const SNSMock = mockClient(SNSClient);

secretsClient.on(GetSecretValueCommand).resolves({SecretString: '{"username": "asdad", "password": "asdas"}'});

beforeEach(() => {
  ddbMock.reset();
  SQSMock.reset();
  SNSMock.reset();
  SQSMock.on(SendMessageCommand).resolves({
    MessageId : "someId"
  });
  SNSMock.on(PublishCommand).resolves({
    MessageId : "someId"
  });
  ddbMock.on(ExecuteStatementCommand).callsFake(input => {
    return Promise.resolve({Id: 'efg'});
  })
  .on(DescribeStatementCommand).callsFake(input => {
    return Promise.resolve({Status : "FINISHED", Id: "efg", HasResultSet: false});
  })
  .on(GetStatementResultCommand).callsFake(input => {
    return Promise.resolve(redshiftResponse);
  });
});

afterEach(jest.clearAllMocks);

In this case, the module that is using the SDK accepts JSON, builds the SQL and handles communication with Redshift. I’ve tried mocking the module instead of the SDK, which does work, but I am unable to validate the final SQL that is going to be sent to AWS. This is a requirement of the project I am working on.

How to fix press button problem on chrome?

I have game. When click right button then element move. But when I press button then show downloading menu and element not move. Problem is in chrome on android.

  $('#right').on('mousedown touchstart', function(e) {
   
    timeOut2 = setInterval(function(){

    
    delta=5;
    
    


    }, 25);
  }).bind('mouseup mouseleave touchend', function() {
    $(this).removeClass('active');
    clearInterval(timeOut2);
  });

How to fix it?

Nodemailer Error occurred: Connection timeout

I’m using node mailer to send email. Here is the code I use:

let transporter = nodemailer.createTransport({
        host: 'smtp.gmail.com',
        port: 465,
        secure: true,
        auth: {
            user: 'email',
            pass: 'password',
        },
        secureConnection: true,
        tls: {
            rejectUnauthorized: false,
        },
    });

locally it works, but once it’s deployed to vercel servers it throws error

Error occurred: Connection timeout

How this could be fixed?

I tried multiple versions of createTransport and nothing works. Is this firewall issue and if so who should I contact ?