Skip to content

[BUG] on.exit causing crashes #22

@smusali

Description

@smusali

One of the changes I have included in #21 is to turn off on.exit in extras/CodeToRun*.R because of the following error while running those scripts on MacOS:

Error in `.createErrorReport()`:
! Error executing SQL:
Invalid or closed connection
An error report has been created at  .../Trajectories/errorReportSql.txt

errorReportSql.txt says the following:

DBMS:
sqlite

Error:
Invalid or closed connection

SQL:
SELECT COUNT(*) AS CCC FROM main.cohort WHERE cohort_definition_id = 1;

R version:
R version 4.2.2 (2022-10-31)

Platform:
aarch64-apple-darwin20

Attached base packages:
- stats
- graphics
- grDevices
- utils
- datasets
- methods
- base

Other attached packages:
- stringi (1.7.12)
- Eunomia (1.0.2)
- drat (0.2.3)
- DatabaseConnector (6.0.0)
- Trajectories (1.0.0)
- dplyr (1.1.0)

Turning off on.exit solves the issue because at the end of each script, it quits by disconnecting from the database with the following commands:

DatabaseConnector::disconnect(connection)

We need to safely and gracefully exit by disconnecting in the case of error only but I couldn't find a way to replace on.exit for such cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions