Discord.js Commando Broadcast All command error - discord.js

I'm trying to make broadcast command send a message to all text channels in the guild. My current code looks like this:
const discord = require('discord.js');
const Commando = require('discord.js-commando');
module.exports = class broadcastCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'broadcast',
aliases: ['bcast', 'bc'],
group: 'ebs',
memberName: 'broadcast',
userPermissions: ['MANAGE_MESSAGES'],
description: 'Sends an emergency broadcast to the emergency brodcast channel',
examples: ['bc ALERT! SUSPICIOUS ENTITY SPOTTED IN DELTA QUADRANT SECTOR B-3! ALL PERSONEL PROCEED WITH CAUTION!'],
args: [
{
key: 'text',
prompt: 'What would you like to broadcast?',
type: 'string',
},
],
})
};
run(msg, { text }) {
let channel = msg.guild.channels.forEarch(channel => {
if (channel.type === 'text') channel.send(`${text}`); {
tts: true
};
})
}
};
My issue is that it gives me a error on using it. This is the error:
11|EBS | at CommandoClient.emit (events.js:314:20)
11|EBS | at GuildMemberRemoveAction.handle (/home/nimbi/ebs/node_modules/discord.js/src/client/actions/GuildMemberRemove.js:20:62)
11|EBS | at GuildMemberRemoveHandler.handle (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/packets/handlers/GuildMemberRemove.js:9:38)
11|EBS | at WebSocketPacketManager.handle (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
11|EBS | at WebSocketConnection.onPacket (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
11|EBS | at WebSocketConnection.onMessage (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
11|EBS | at WebSocket.onMessage (/home/nimbi/ebs/node_modules/ws/lib/event-target.js:120:16)
11|EBS | at WebSocket.emit (events.js:314:20)
11|EBS | at Receiver.receiverOnMessage (/home/nimbi/ebs/node_modules/ws/lib/websocket.js:789:20)
11|EBS | /home/nimbi/ebs/EBS.sh: line 1: !#/bin/sh: No such file or directory
11|EBS | (node:28491) DeprecationWarning: Collection#filterArray: use Collection#filter instead
11|EBS | (Use `node --trace-deprecation ...` to show where the warning was created)
11|EBS | /home/nimbi/ebs/EBS.sh: line 1: !#/bin/sh: No such file or directory
11|EBS | (node:22022) DeprecationWarning: Collection#filterArray: use Collection#filter instead
11|EBS | (Use `node --trace-deprecation ...` to show where the warning was created)
I'm trying to figure out how to implement this. It's needed for a SciFi LARP server that I'm helping a friend build.
I'm on Node 12.x and using Discord.JS Commando
I've also tried this:
const discord = require('discord.js');
const Commando = require('discord.js-commando');
module.exports = class broadcastCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'broadcast',
aliases: ['ebcast', 'bcast', 'bc', 'ebc'],
group: 'ebs',
memberName: 'broadcast',
userPermissions: ['MANAGE_MESSAGES'],
description: 'Sends an emergency broadcast to the emergency brodcast channel',
examples: ['bc ALERT! SUSPICIOUS ENTITY SPOTTED IN DELTA QUADRANT SECTOR B-3! ALL PERSONEL PROCEED WITH CAUTION!'],
args: [
{
key: 'text',
prompt: 'What would you like to broadcast?',
type: 'string',
},
],
})
};
run(msg, { text }) {
const channels = msg.guild.channels.filter(c => c.guild && c.type === 'text');
Promise.all(channels.map(c => c.send(`${text}`))); {
tts: true
};
}
};
However it gave this error:
11|EBS | at WebSocketPacketManager.handle (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
11|EBS | at WebSocketConnection.onPacket (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
11|EBS | at WebSocketConnection.onMessage (/home/nimbi/ebs/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
11|EBS | at WebSocket.onMessage (/home/nimbi/ebs/node_modules/ws/lib/event-target.js:120:16)
11|EBS | at WebSocket.emit (events.js:314:20)
11|EBS | at Receiver.receiverOnMessage (/home/nimbi/ebs/node_modules/ws/lib/websocket.js:789:20)
11|EBS | /home/nimbi/ebs/EBS.sh: line 1: !#/bin/sh: No such file or directory
11|EBS | (node:28491) DeprecationWarning: Collection#filterArray: use Collection#filter instead
11|EBS | (Use `node --trace-deprecation ...` to show where the warning was created)
11|EBS | /home/nimbi/ebs/EBS.sh: line 1: !#/bin/sh: No such file or directory
11|EBS | (node:22022) DeprecationWarning: Collection#filterArray: use Collection#filter instead
11|EBS | (Use `node --trace-deprecation ...` to show where the warning was created)
11|EBS | /home/nimbi/ebs/EBS.sh: line 1: !#/bin/sh: No such file or directory
11|EBS | (node:22853) DeprecationWarning: Collection#filterArray: use Collection#filter instead
11|EBS | (Use `node --trace-deprecation ...` to show where the warning was created)
Another thing I've tried is this:
const discord = require('discord.js');
const Commando = require('discord.js-commando');
module.exports = class broadcastCommand extends Commando.Command {
constructor(client) {
super(client, {
name: 'broadcast',
aliases: ['ebcast', 'bcast', 'bc', 'ebc'],
group: 'ebs',
memberName: 'broadcast',
userPermissions: ['MANAGE_MESSAGES'],
description: 'Sends an emergency broadcast to the emergency brodcast channel',
examples: ['bc ALERT! SUSPICIOUS ENTITY SPOTTED IN DELTA QUADRANT SECTOR B-3! ALL PERSONEL PROCEED WITH CAUTION!'],
args: [
{
key: 'text',
prompt: 'What would you like to broadcast?',
type: 'string',
},
],
})
};
run(msg, { text }) {
const channel_list = msg.guild.channels.find(c => c.id === ['759042556972630036', '759042556972630037', '759042556972630038', '759061573867405312', '759042556536553557', '759801988560322611', '759116305218666496'])
return channel_list.send(`${ text }`); {
tts: true
};
}
};
However that failed as well.

You're reasonably on the right track. The biggest issue is that you define the MessageOptions outside of the .send function.
Check the code example below and give it a try.
run(msg, { text}) {
// Note if you're using Discord JS version 12.0.0 or higher, you need to use '.channels.cache'
// If you're using Discord JS version 11.1.0 or lower, remove the '.cache'
msg.guild.channels.cache
.filter(channel => channel.type === 'text')
.forEach((textChannel) => {
textChannel.send(text, {tts: true});
});
}

Related

Assigning values to arrays with dynamic keys in nested objects in javascript

I have problems understanding and creating dynamic keys of an object and assigning values to nested objects.
desired output:
{
SULS: {
"Main Site": ["Home Page", "Login Page", "Register Page"],
"Judge Site": ["Login Page", "Submittion Page"],
"Digital Site": ["Login Page"],
},
Lamba: {
CoreA: ["A23", "A24", "A25"],
CoreB: ["B24"],
},
Indice: {
Session: ["Default Storage", "Default Security"]
},
}
here is the input:
system([
"SULS | Main Site | Home Page",
"SULS | Main Site | Login Page",
"SULS | Main Site | Register Page",
"SULS | Judge Site | Login Page",
"SULS | Judge Site | Submittion Page",
"Lambda | CoreA | A23",
"SULS | Digital Site | Login Page",
"Lambda | CoreB | B24",
"Lambda | CoreA | A24",
"Lambda | CoreA | A25",
"Lambda | CoreC | C4",
"Indice | Session | Default Storage",
"Indice | Session | Default Security",
]);
This is what i have been trying and keep getting errors while constructing the nested object:
function system(components) {
let obj = components.reduce((mainObj, input) => {
let [systemName, component, subComponent] = input.split(" | ");
return {
...mainObj,
[systemName]: {
...(mainObj[systemName] || {}),
[component]: [...(mainObj[systemName][component] || []), subComponent],
},
};
}, {});
console.log(obj);
}
I have been stucked for a few days and appreciate if anyone can help
Your code has the correct logic. There is just an error on this line:
[component]: [...(mainObj[systemName][component] || []), subComponent],
...when mainObj[systemName] is still undefined.
This is easily solved with optional chainging:
[component]: [...(mainObj[systemName]?.[component] || []), subComponent],

when user want to login : AXIOS ERROR: [Error: Request failed with status code 401] BAD_REQUEST

i have a react native app and want to login EXISTING USER IN DATABASE with username and password for get the accesstoken and refreshtoken from api/login. but i get 401 error .
error in docker log:
app_1 | 2022-06-23 20:56:55.997 ERROR 1 --- [nio-8080-exec-3] c.r.hamsafar
.service.UsersServiceImpl : User Not Found In Database
app_1 | Hibernate:
app_1 | select
app_1 | users0_.id as id1_1_,
app_1 | users0_.activation_code as activati2_1_,
app_1 | users0_.active as active3_1_,
app_1 | users0_.disabled as disabled4_1_,
app_1 | users0_.failed_try_count as failed_t5_1_,
app_1 | users0_.family as family6_1_,
app_1 | users0_.lock_time as lock_tim7_1_,
app_1 | users0_.name as name8_1_,
app_1 | users0_.national_code as national9_1_,
app_1 | users0_.password as passwor10_1_,
app_1 | users0_.sms_time as sms_tim11_1_,
app_1 | users0_.username as usernam12_1_
app_1 | from
app_1 | users users0_
app_1 | where
app_1 | users0_.username=?
This is while the user is in the database and it works with the same username and password correctly and without error in postman.
axios codes:
var formData = new FormData();
formData.append('username', '0123456789');
formData.append('password', '0123456789');
axios.post(
'http://1.2.3.4:5555/api/login'
, { formData })
.then(response => {
console.log("RESPONSE RECEIVED: ", response);
})
.catch((err) => {
console.log("AXIOS ERROR: ", err);
})
please help me
Often these types of error is because your server expects a content-type header, in order to understand how to parse the request body (your form in this case).
Look closely at the request from Postman that works, what does it have that you're omitting in your code?
If you've added form data, I believe postman automatically adds the Content-Type header for the appropriate data you've added.
Try editing your code to something like this (removed wrapping formData in an object & added multipart/form-data content-type header):
var formData = new FormData();
formData.append('username', '0123456789');
formData.append('password', '0123456789');
axios.post('http://1.2.3.4:5555/api/login', formData, {
headers: {
'Content-Type': 'multipart/form-data',
}
})
.then((response) => {
console.log('RESPONSE RECEIVED: ', response);
})
.catch((err) => {
console.log('AXIOS ERROR: ', err);
});
Update based on comment revealing Postman using Content-Type application/json:
Try changing header & body to json instead, if that's what your server expects & works in postman:
const data = { username: '0123456789', password: '0123456789' };
axios.post('http://1.2.3.4:5555/api/login', data, {
headers: {
'Content-Type': 'application/json',
}
})
.then((response) => {
console.log('RESPONSE RECEIVED: ', response);
})
.catch((err) => {
console.log('AXIOS ERROR: ', err);
});
https://stackoverflow.com/users/6730803/fredrik-sch%c3%b6n
https://stackoverflow.com/users/10237430/abir-taheer
i solved my problem with used the username and password in url like this:
'http://1.2.3.4:5555/api/login?username='0123456789'&password='0123456789''
thank you from :
https://stackoverflow.com/users/6730803/fredrik-sch%c3%b6n
&
https://stackoverflow.com/users/10237430/abir-taheer
&
https://stackoverflow.com

fetchMock error on testing RTK-query with jest (react Vite.js)

just tried to mocked the store then test the request with fetchMock but got this error :
you can check out the full repo on :
https://github.com/alibidjandy/layered-architecture
src/app/main/__tests__/main.test.tsx (5.569 s)
● Console
console.warn
Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments.
7 | reducerPath: "productService",
8 | tagTypes: ["product"],
> 9 | baseQuery: fetchBaseQuery({
| ^
10 | baseUrl: serviceURL,
11 | }),
12 | endpoints: (builder) => ({}),
at fetchBaseQuery (node_modules/#reduxjs/toolkit/src/query/fetchBaseQuery.ts:180:13)
at Object.<anonymous> (src/app/main/data/api/service.ts:9:28)
at Object.<anonymous> (src/app/main/data/api/store.ts:3:1)
FAIL src/app/components/products/tests/products-requests.test.tsx
● Test suite failed to run
src/app/components/products/__tests__/products-requests.test.tsx:14:3 - error TS2304: Cannot find name 'fetchMock'.
14 fetchMock.resetMocks();
~~~~~~~~~
src/app/components/products/__tests__/products-requests.test.tsx:24:5 - error TS2304: Cannot find name 'fetchMock'.
24 fetchMock.mockResponse(JSON.stringify(dummyProducts));
~~~~~~~~~
src/app/components/products/__tests__/products-requests.test.tsx:41:5 - error TS2304: Cannot find name 'fetchMock'.
41 fetchMock.mockReject(new Error("Internal Server Error"));
~~~~~~~~~
src/app/components/products/__tests__/products-requests.test.tsx:61:5 - error TS2304: Cannot find name 'fetchMock'.
61 fetchMock.mockResponse(JSON.stringify(dummyProducts));
~~~~~~~~~
src/app/components/products/__tests__/products-requests.test.tsx:85:5 - error TS2304: Cannot find name 'fetchMock'.
85 fetchMock.mockReject(new Error("Internal Server Error"));
~~~~~~~~~
FAIL src/app/main/tests/service.test.ts (15.706 s)
● getProductById › request is correct
expect(jest.fn()).toBeCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
20 | .dispatch<any>(getProducts.initiate(undefined))
21 | .then(() => {
> 22 | expect(fetchMock).toBeCalledTimes(1);
| ^
23 | const { method, url } = fetchMock.mock.calls[0][0] as Request;
24 |
25 | expect(method).toBe("GET");
at src/app/main/__tests__/service.test.ts:22:27
● getProductById › unsuccessful response
TypeError: Cannot read property 'error' of undefined
51 | const {
52 | status,
> 53 | error: { error },
| ^
54 | isError,
55 | } = action;
56 | expect(status).toBe("rejected");
at src/app/main/__tests__/service.test.ts:53:20
● getProductById › request is correct
expect(jest.fn()).toBeCalledTimes(expected)
Expected number of calls: 1
Received number of calls: 0
69 | .dispatch<any>(getProductById.initiate(dummyProduct.id))
70 | .then(() => {
> 71 | expect(fetchMock).toBeCalledTimes(1);
| ^
72 | const request = fetchMock.mock.calls[0][0] as Request;
73 | const { method, url } = request;
74 |
at src/app/main/__tests__/service.test.ts:71:27
● getProductById › unsuccessful response
TypeError: Cannot read property 'error' of undefined
102 | const {
103 | status,
> 104 | error: { error },
| ^
105 | isError,
106 | } = action;
107 | expect(status).toBe("rejected");
at src/app/main/__tests__/service.test.ts:104:20
Test Suites: 2 failed, 1 passed, 3 total
Tests: 4 failed, 3 passed, 7 total
Snapshots: 0 total
Time: 17.642 s
Ran all test suites.
install whatwg-fetch
after install it add import 'whatwg-fetch'; at the beginning (line 1) of the file.test youre using
The test in Jest doesn't run on the browser. It runs on NodeJS. So, you need a polyfill for the "fetch".
There are many options on NPM, but some of them haven't worked for me.
The one that worked fine was the cross-fetch: https://www.npmjs.com/package/cross-fetch
It works on browser/NodeJS/Mobile. You just need to add it to package.json (devDependencies) and import it on jest.setup.js file:
import 'cross-fetch/polyfill';

Converting a message in a channel into an embed

I am currently trying to script that when a person sends a message to a specific channel, that message is then automatically converted to an embed. For me the conversion works the first time but not the second time. I'm always getting an error after the messages was converted.
My Script:
const channel = "905504402276765766";
if(channel.includes(message.channel.id))
var test = message.content.slice(" ")
const tryembed = new Discord.MessageEmbed()
.setColor('DARK_RED')
.setTitle('Test')
.addFields(
{name: "Person who wants to report a bug:", value: `<#!${message.author.id}>`},
{name: "Bug that was reported:", value: test}
)
message.channel.send({embeds: [tryembed]})
message.delete()
My error Code:
C:\Discord Bots\Bot v13\node_modules\discord.js\src\util\Util.js:414
if (!allowEmpty && data.length === 0) throw new error(errorMessage);
^
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
at Function.verifyString (C:\Discord Bots\Bot v13\node_modules\discord.js\src\util\Util.js:414:49)
at Function.normalizeField (C:\Discord Bots\Bot v13\node_modules\discord.js\src\structures\MessageEmbed.js:441:19)
at C:\Discord Bots\Bot v13\node_modules\discord.js\src\structures\MessageEmbed.js:462:14
at Array.map (<anonymous>)
at Function.normalizeFields (C:\Discord Bots\Bot v13\node_modules\discord.js\src\structures\MessageEmbed.js:461:8)
at MessageEmbed.addFields (C:\Discord Bots\Bot v13\node_modules\discord.js\src\structures\MessageEmbed.js:283:42)
at Client.<anonymous> (C:\Discord Bots\Bot v13\index.js:44:2)
at Client.emit (node:events:394:28)
at MessageCreateAction.handle (C:\Discord Bots\Bot v13\node_modules\discord.js\src\client\actions\MessageCreate.js:23:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\Discord Bots\Bot v13\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) {
[Symbol(code)]: 'EMBED_FIELD_VALUE'
}
Using value: `** ** ${test}` will solve your problem, so you need to change your {name: "Bug that was reported:", value: test} to:
{name: "Bug that was reported:", value: `** ** ${test}`}

SQL Server using TypeORM: Error Timeout: Request failed to complete when inserting records by batch

The issue I am having is that when I run the migration command I always get an ETIMEOUT error, but if I comment out the await populateTable() the code will run without any error.
I already tried to increase the requestTimeout from 15sec to 300sec but that didn't help.
Here's my code:
Create the following:
// ormconfig.json
[
{
"name": "app",
"type": "mssql",
"host": "127.0.0.1",
"port": 1433,
"username": "root",
"password": "root",
"database": "app",
"logging": true,
"options": {
"useUTC": true
},
"entities": ["src/**/*.entity.ts"],
"migrations": ["migration/**/*.ts"],
"cli": {
"migrationsDir": "migration"
}
}
]
// root-dir/src/grouping/grouping.entity.ts
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
#Entity({ name: 'grouping' })
export class Grouping {
#PrimaryGeneratedColumn({ name: 'id', unsigned: true })
id: number;
#Column({ name: 'name', unique: true })
name: string;
}
// root-dir/migration/tables/grouping.ts
import { getRepository, QueryRunner, Table, TableIndex } from 'typeorm';
import { Grouping } from '../../src/grouping/grouping.entity';
export async function up(queryRunner: QueryRunner): Promise<any> {
await createTable(queryRunner);
await createIndexes(queryRunner);
await populateTable();
}
export async function down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropIndex('grouping', 'IDX_GROUP');
await queryRunner.dropTable('grouping');
}
async function createTable(queryRunner: QueryRunner) {
return queryRunner.createTable(
new Table({
name: 'grouping',
columns: [
{
name: 'id',
type: 'integer',
isPrimary: true,
isGenerated: true,
generationStrategy: 'increment',
unsigned: true,
},
{
name: 'name',
type: 'varchar',
isUnique: true,
},
],
}),
true,
);
}
async function createIndexes(queryRunner: QueryRunner) {
return await queryRunner.createIndex(
'grouping',
new TableIndex({
name: 'IDX_GROUP',
columnNames: ['name'],
}),
);
}
async function populateTable() {
await getRepository(Grouping, 'app').save([{ name: 'classification' }, { name: 'categorization' }]);
}
// root-dir/migration/initial-migration.ts
import { MigrationInterface, QueryRunner } from 'typeorm';
import * as groupingTable from './tables/grouping';
export class InitialMigration1550229771145 implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<any> {
await groupingTable.up(queryRunner);
}
async down(queryRunner: QueryRunner): Promise<any> {
await groupingTable.down(queryRunner);
}
}
Run the migration command.
ts-node ./node_modules/typeorm/cli.js migration:run -c
This should create the Grouping table and insert 2 records but what I am getting is this error:
Query: CREATE TABLE "grouping" ("id" integer NOT NULL IDENTITY(1,1), "name" varchar(255) NOT NULL, CONSTRAINT "UQ_07314fe287a837177015c041131" UNIQUE ("name"), CONSTRAINT "PK_135d73da7246e0250716afdc0ab" PRIMARY KEY ("id"))
query: SELECT SCHEMA_NAME() AS "schema_name"
query: SELECT DB_NAME() AS "db_name"
query: SELECT * FROM "app"."INFORMATION_SCHEMA"."TABLES" WHERE ("TABLE_SCHEMA" = 'dbo' AND "TABLE_NAME" = 'grouping')
query: SELECT * FROM "app"."INFORMATION_SCHEMA"."COLUMNS" WHERE ("TABLE_SCHEMA" = 'dbo' AND "TABLE_NAME" = 'grouping')
query: SELECT "columnUsages".*, "tableConstraints"."CONSTRAINT_TYPE", "chk"."definition" FROM "app"."INFORMATION_SCHEMA"."CONSTRAINT_COLUMN_USAGE" "columnUsages" INNER JOIN "app"."INFORMATION_SCHEMA"."TABLE_CONSTRAINTS" "tableConstraints" ON "tableConstraints"."CONSTRAINT_NAME" = "columnUsages"."CONSTRAINT_NAME" LEFT JOIN "app"."sys"."check_constraints" "chk" ON "chk"."name" = "columnUsages"."CONSTRAINT_NAME" WHERE (("columnUsages"."TABLE_SCHEMA" = 'dbo' AND "columnUsages"."TABLE_NAME" = 'grouping' AND "tableConstraints"."TABLE_SCHEMA" = 'dbo' AND "tableConstraints"."TABLE_NAME" = 'grouping')) AND "tableConstraints"."CONSTRAINT_TYPE" IN ('PRIMARY KEY', 'UNIQUE', 'CHECK')
query: SELECT "fk"."name" AS "FK_NAME", 'app' AS "TABLE_CATALOG", "s1"."name" AS "TABLE_SCHEMA", "t1"."name" AS "TABLE_NAME", "col1"."name" AS "COLUMN_NAME", "s2"."name" AS "REF_SCHEMA", "t2"."name" AS "REF_TABLE", "col2"."name" AS "REF_COLUMN", "fk"."delete_referential_action_desc" AS "ON_DELETE", "fk"."update_referential_action_desc" AS "ON_UPDATE" FROM "app"."sys"."foreign_keys" "fk" INNER JOIN "app"."sys"."foreign_key_columns" "fkc" ON "fkc"."constraint_object_id" = "fk"."object_id" INNER JOIN "app"."sys"."tables" "t1" ON "t1"."object_id" = "fk"."parent_object_id" INNER JOIN "app"."sys"."schemas" "s1" ON "s1"."schema_id" = "t1"."schema_id" INNER JOIN "app"."sys"."tables" "t2" ON "t2"."object_id" = "fk"."referenced_object_id" INNER JOIN "app"."sys"."schemas" "s2" ON "s2"."schema_id" = "t2"."schema_id" INNER JOIN "app"."sys"."columns" "col1" ON "col1"."column_id" = "fkc"."parent_column_id" AND "col1"."object_id" = "fk"."parent_object_id" INNER JOIN "app"."sys"."columns" "col2" ON "col2"."column_id" = "fkc"."referenced_column_id" AND "col2"."object_id" = "fk"."referenced_object_id"
query: SELECT "TABLE_CATALOG", "TABLE_SCHEMA", "COLUMN_NAME", "TABLE_NAME" FROM "app"."INFORMATION_SCHEMA"."COLUMNS" WHERE COLUMNPROPERTY(object_id("TABLE_CATALOG" + '.' + "TABLE_SCHEMA" + '.' + "TABLE_NAME"), "COLUMN_NAME", 'IsIdentity') = 1 AND "TABLE_SCHEMA" IN ('dbo')
query: SELECT "NAME", "COLLATION_NAME" FROM "sys"."databases"
query: SELECT 'app' AS "TABLE_CATALOG", "s"."name" AS "TABLE_SCHEMA", "t"."name" AS "TABLE_NAME", "ind"."name" AS "INDEX_NAME", "col"."name" AS "COLUMN_NAME", "ind"."is_unique" AS "IS_UNIQUE", "ind"."filter_definition" as "CONDITION" FROM "app"."sys"."indexes" "ind" INNER JOIN "app"."sys"."index_columns" "ic" ON "ic"."object_id" = "ind"."object_id" AND "ic"."index_id" = "ind"."index_id" INNER JOIN "app"."sys"."columns" "col" ON "col"."object_id" = "ic"."object_id" AND "col"."column_id" = "ic"."column_id" INNER JOIN "app"."sys"."tables" "t" ON "t"."object_id" = "ind"."object_id" INNER JOIN "app"."sys"."schemas" "s" ON "s"."schema_id" = "t"."schema_id" WHERE "ind"."is_primary_key" = 0 AND "ind"."is_unique_constraint" = 0 AND "t"."is_ms_shipped" = 0
query: CREATE INDEX "IDX_GROUP" ON "grouping" ("name")
query: BEGIN TRANSACTION
query: INSERT INTO "grouping"("name") OUTPUT INSERTED."id" VALUES (#0), (#1) -- PARAMETERS: [{"value":"classification","type":"nvarchar","params":[]},{"value":"categorization","type":"nvarchar","params":[]}]
query failed: INSERT INTO "grouping"("name") OUTPUT INSERTED."id" VALUES (#0), (#1) -- PARAMETERS: [{"value":"classification","type":"nvarchar","params":[]},{"value":"categorization","type":"nvarchar","params":[]}]
error: { RequestError: Timeout: Request failed to complete in 15000ms
at Request.tds.Request.err [as userCallback] (C:\Users\me\Workspace\app\api\node_modules\mssql\lib\tedious.js:629:19)
at Request.callback (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\request.js:37:27)
at Connection.message (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:2136:24)
at Connection.dispatchEvent (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:1084:36)
at MessageIO.messageIo.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:984:14)
at MessageIO.emit (events.js:189:13)
at MessageIO.EventEmitter.emit (domain.js:441:20)
at Message.message.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\message-io.js:32:14)
at Message.emit (events.js:194:15)
at Message.EventEmitter.emit (domain.js:441:20)
code: 'ETIMEOUT',
number: 'ETIMEOUT',
state: undefined,
originalError:
{ RequestError: Timeout: Request failed to complete in 15000ms
at RequestError (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\errors.js:32:12)
at Connection.message (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:2136:33)
at Connection.dispatchEvent (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:1084:36)
at MessageIO.messageIo.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:984:14)
at MessageIO.emit (events.js:189:13)
at MessageIO.EventEmitter.emit (domain.js:441:20)
at Message.message.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\message-io.js:32:14)
at Message.emit (events.js:194:15)
at Message.EventEmitter.emit (domain.js:441:20)
at endReadableNT (C:\Users\me\Workspace\app\api\node_modules\tedious\node_modules\readable-stream\lib_stream_readable.js:1077:12)
message: 'Timeout: Request failed to complete in 15000ms',
code: 'ETIMEOUT' },
name: 'RequestError',
precedingErrors: [] }
query: ROLLBACK
query: ROLLBACK
Error during migration run:
{ QueryFailedError: Error: Timeout: Request failed to complete in 15000ms
at new QueryFailedError (C:\Users\me\Workspace\app\api\src\error\QueryFailedError.ts:9:9)
at C:\Users\me\Workspace\app\api\src\driver\sqlserver\SqlServerQueryRunner.ts:221:37
at _query (C:\Users\me\Workspace\app\api\node_modules\mssql\lib\base.js:1346:25)
at Request.tds.Request.err [as userCallback] (C:\Users\me\Workspace\app\api\node_modules\mssql\lib\tedious.js:671:15)
at Request.callback (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\request.js:37:27)
at Connection.message (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:2136:24)
at Connection.dispatchEvent (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:1084:36)
at MessageIO.messageIo.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:984:14)
at MessageIO.emit (events.js:189:13)
at MessageIO.EventEmitter.emit (domain.js:441:20)
message: 'Error: Timeout: Request failed to complete in 15000ms',
code: 'ETIMEOUT',
number: 'ETIMEOUT',
state: undefined,
originalError:
{ RequestError: Timeout: Request failed to complete in 15000ms
at RequestError (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\errors.js:32:12)
at Connection.message (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:2136:33)
at Connection.dispatchEvent (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:1084:36)
at MessageIO.messageIo.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\connection.js:984:14)
at MessageIO.emit (events.js:189:13)
at MessageIO.EventEmitter.emit (domain.js:441:20)
at Message.message.on (C:\Users\me\Workspace\app\api\node_modules\tedious\lib\message-io.js:32:14)
at Message.emit (events.js:194:15)
at Message.EventEmitter.emit (domain.js:441:20)
at endReadableNT (C:\Users\me\Workspace\app\api\node_modules\tedious\node_modules\readable-stream\lib_stream_readable.js:1077:12)
message: 'Timeout: Request failed to complete in 15000ms',
code: 'ETIMEOUT' },
name: 'QueryFailedError',
precedingErrors: [],
query:
'INSERT INTO "grouping"("name") OUTPUT INSERTED."id" VALUES (#0), (#1)',
parameters:
[ MssqlParameter { value: 'classification', type: 'nvarchar', params: [] },
MssqlParameter { value: 'categorization', type: 'nvarchar', params: [] } ] }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-api#0.1.0 migration:run: ts-node ./node_modules/typeorm/cli.js migration:run -c "app_engine"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app-api#0.1.0 migration:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache_logs\2019-06-04T18_56_36_972Z-debug.log
Any help is greatly appreciated!
Update:
I found this https://github.com/typeorm/typeorm/issues/3100#issuecomment-446309812 while browsing through the previous issues and it is now working.
try to use a legacy version of the npm i mssql # 5.1.1 driver --save

Resources