Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlite3: add interrupt method #40747

Merged
merged 1 commit into from
Dec 20, 2019

Conversation

mtgto
Copy link
Contributor

@mtgto mtgto commented Nov 30, 2019

Add interrupt to type definition. This function is released since v3.1.5 (5 Oct 2016).

TryGhost/node-sqlite3#518
https://github.com/mapbox/node-sqlite3/blob/4f61a03c60cb827b7cad7f624f34e607779b85d9/CHANGELOG.md#315

P.S. API document of node-sqlite3 doesn't have interrupt now.
TryGhost/node-sqlite3#1205 (comment)

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: Add support for sqlite3_interrupt TryGhost/node-sqlite3#518
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the header.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.

@@ -89,6 +89,7 @@ export class Database extends events.EventEmitter {
on(event: string, listener: (...args: any[]) => void): this;

configure(option: "busyTimeout", value: number): void;
interrupt(): void;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may throw an error.
For example, error has happened when database is not opened:

$ node index.js
/Users/user/work/js/test-sqlite3/index.js:3
db.interrupt();
   ^

Error: Database is not open
    at Object.<anonymous> (/Users/user/work/js/test-sqlite3/index.js:3:4)
    at Module._compile (internal/modules/cjs/loader.js:1121:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
    at Module.load (internal/modules/cjs/loader.js:976:32)
    at Function.Module._load (internal/modules/cjs/loader.js:884:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:67:12)
    at internal/main/run_main_module.js:17:47

Source:

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(':memory:');
db.interrupt();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not cause an error.

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database(':memory:');
db.each('select 1', err => {
  db.interrupt();
});

@typescript-bot
Copy link
Contributor

👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings.

Let’s review the numbers, shall we?

Comparison details 📊
master #40747 diff
Batch compilation
Memory usage (MiB) 67.3 69.3 +3.0%
Type count 8528 8532 0%
Assignability cache size 908 908 0%
Language service
Samples taken 147 152 +3%
Identifiers in tests 147 152 +3%
getCompletionsAtPosition
    Mean duration (ms) 324.8 326.6 +0.5%
    Mean CV 10.8% 11.6%
    Worst duration (ms) 409.6 457.2 +11.6%
    Worst identifier close log
getQuickInfoAtPosition
    Mean duration (ms) 324.4 328.1 +1.2%
    Mean CV 11.1% 11.2% +0.6%
    Worst duration (ms) 392.7 437.4 +11.4%
    Worst identifier sqlite log

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Nov 30, 2019
@typescript-bot
Copy link
Contributor

typescript-bot commented Nov 30, 2019

@mtgto Thank you for submitting this PR!

🔔 @nmalaguti @dpyro @BehindTheMath - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Dec 5, 2019
@typescript-bot
Copy link
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@DanielRosenwasser DanielRosenwasser merged commit 4cfb86e into DefinitelyTyped:master Dec 20, 2019
@DanielRosenwasser
Copy link
Member

Thanks for the patience!

@mtgto
Copy link
Contributor Author

mtgto commented Dec 20, 2019

Thanks for your review 😺

@mtgto mtgto deleted the sqlite3_interrupt branch December 20, 2019 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Unmerged The author did not merge the PR when it was ready.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants