Skip to content

Commit

Permalink
Server does not crash for invalid slicing criteria (#423)
Browse files Browse the repository at this point in the history
refactor: guard slicer execution with `catch` clauses
  • Loading branch information
EagleoutIce authored Oct 17, 2023
1 parent 20f53de commit 52a6521
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cli/repl/server/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ export class FlowRServerConnection {
const slicer = this.createSteppingSlicerForRequest(message)

void slicer.allRemainingSteps(false).then(async results => await this.sendFileAnalysisResponse(results, message))
.catch(e => {
this.logger.error(`[${this.name}] Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`)
sendMessage<FlowrErrorMessage>(this.socket, {
id: message.id,
type: 'error',
fatal: false,
reason: `Error while analyzing file ${message.filename ?? 'unknown file'}: ${String(e)}`
})
})
}

private async sendFileAnalysisResponse(results: Partial<StepResults<typeof LAST_STEP>>, message: FileAnalysisRequestMessage): Promise<void> {
Expand Down Expand Up @@ -201,6 +210,14 @@ export class FlowRServerConnection {
id: request.id,
results: Object.fromEntries(Object.entries(results).filter(([k,]) => Object.hasOwn(STEPS_PER_SLICE, k))) as SliceResponseMessage['results']
})
}).catch(e => {
this.logger.error(`[${this.name}] Error while analyzing file for token ${request.filetoken}: ${String(e)}`)
sendMessage<FlowrErrorMessage>(this.socket, {
id: request.id,
type: 'error',
fatal: false,
reason: `Error while analyzing file for token ${request.filetoken}: ${String(e)}`
})
})
}

Expand Down

2 comments on commit 52a6521

@github-actions
Copy link

Choose a reason for hiding this comment

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

"artificial" Benchmark Suite

Benchmark suite Current: 52a6521 Previous: a13ba7d Ratio
Total per-file 4342.173155227273 ms (5263.271582365764) 5136.292062545455 ms (6659.167699804035) 0.85
Retrieve AST from R code 94.30812204545455 ms (190.09154205267967) 124.09828127272726 ms (243.70782214857047) 0.76
Normalize R AST 133.60361845454545 ms (231.7266593288522) 160.2237915909091 ms (278.6105978575149) 0.83
Produce dataflow information 94.9797445 ms (259.9473343203608) 108.43437586363636 ms (284.0057832037362) 0.88
Total per-slice 2.4234712316555145 ms (1.6301051483477809) 2.8182434778758196 ms (2.051447335915778) 0.86
Static slicing 1.760868278580986 ms (1.5127319225368778) 1.9806726576978653 ms (1.8433455256061702) 0.89
Reconstruct code 0.6383990121130545 ms (0.362412296854297) 0.8126920856475652 ms (0.6147197597624667) 0.79
failed to reconstruct/re-parse 0 # 0 # NaN
times hit threshold 0 # 0 # NaN
reduction (characters) 0.7329390759026896 # 0.7329390759026896 # 1
reduction (normalized tokens) 0.720988345209971 # 0.720988345209971 # 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

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

"social-science" Benchmark Suite

Benchmark suite Current: 52a6521 Previous: a13ba7d Ratio
Total per-file 6795.7810203 ms (8054.2742341182575) 9217.97168212 ms (11233.23134490305) 0.74
Retrieve AST from R code 104.81467714 ms (95.60052454199344) 147.46538397999998 ms (132.5895147714834) 0.71
Normalize R AST 153.15723798 ms (101.51739592190748) 193.47818752 ms (124.29041849585441) 0.79
Produce dataflow information 225.90049472 ms (391.9921249761863) 306.41368989999995 ms (521.6767922234001) 0.74
Total per-slice 11.492153428097623 ms (19.582469342415017) 16.16594832538752 ms (26.82605591153744) 0.71
Static slicing 10.815770085684624 ms (19.46670819919941) 15.202546042225746 ms (26.638722260076488) 0.71
Reconstruct code 0.6624598566607297 ms (0.45614638521771317) 0.9461226541249134 ms (0.6094339586982859) 0.70
failed to reconstruct/re-parse 9 # 9 # 1
times hit threshold 967 # 967 # 1
reduction (characters) 0.8987761232201357 # 0.8987761232201357 # 1
reduction (normalized tokens) 0.8582032343145828 # 0.8582032343145828 # 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.