db.create does not throw an error if a string contains '\n', it just hangs
See original GitHub issueI’m trying to import 17652 rows from SQL Server to SurrealDB to make some tests.
I wrote a small nodejs script that connects to SQL Server, reads the contents of a table and then calls db.create
for each row (maybe a bulk insert method in the future? 😄)
After exactly 9360 rows, every time I tested it, the script just hangs on a db.create
and never returns.
I’m using the standard docker container version of SurrealDB running on Docker Desktop.
import sql from "mssql";
import Surreal from "surrealdb.js";
import _ from "lodash";
async function main() {
const db = new Surreal("http://localhost:8000/rpc");
const config = {
server: "###",
user: "###",
password: "###",
database: "###",
options: {
encrypt: false,
},
};
console.log("Connecting to SQL Server...");
await sql.connect(config);
console.log("Connecting to SurrealDB...");
await db.signin({
user: "###",
pass: "###",
});
await db.use("test", "test");
console.log("Reading rows from the Table...");
const result = await sql.query`SELECT * FROM <tableName>`;
for (const row of result.recordset) {
await db.create(
"item:" + row.Id,
row
);
}
await sql.close();
db.close();
console.log("DONE!");
}
main();
The script is pretty simple as shown above. After it hangs, selecting from SurrealDB shows that exactly 9360 rows where created, on a total of 17652 to be created.
SELECT count() FROM task GROUP BY ALL;
[
{
"time": "107.4225ms",
"status": "OK",
"result": [
{
"count": 9360
}
]
}
]
Am I doing something wrong?
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Simple postgres select query hangs forever when string ...
I am unable to figure out why the following query fails in node.js with pg PostgreSQL client (version 8.5.1). db.query("SELECT id FROM ...
Read more >Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >10 Handling PL/SQL Errors
If no exception has been raised, SQLCODE returns zero and SQLERRM returns the message: ORA-0000: normal, successful completion . You can pass an...
Read more >How to Throw Exceptions in Node.js - Rollbar
SyntaxError: these errors come from invalid code; TypeError: this occurs when you attempt to use a variable that is not a valid type;...
Read more >Better Error Handling In NodeJS With Error Classes
This article is for JavaScript and NodeJS developers who want to improve error-handling in their applications.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @LeoDog896 , @Balrog994 , there is a fix coming to the database for this, and a new beta release coming this weekend!
It will support escaped characters like in JSON strings (
\b
,\n
,\f
,\r
,\t
) and unicode characters\u1234
.Absolutely @abdoufma 👍